105 users online (1 members and 104 guests)  

  Results 1 to 3 of 3


  1. Replies: 1
  2. Replies: 3
  3. Form drop down menu tool tips?    Forum: CSS Forum
    Replies: 0
  4. Replies: 1
  5. Replies: 2
  1. #1
    lozza's Avatar
    New User

    Join Date
    Sep 2008

    PHP Form menu: POST to same page problem

    Hi all - I apologize if this is an easily solvable problem - I have searched the forums and found nothing that matches what I am trying to do.

    I have an ecommerce site I am trying to get up and running...one problem I have encountered is getting my form to post its results to the "hidden" string within the URL that resides in my "Buy now Button" on the SAME page. It would be:

    Form results: size = Large

    inserted into product_size:

    <a href="https://www.adresshere.asp?merchant_id=0001&product_size=*Large*....etc etc".

    My code for the form is:
    <form id="form1" name="form1" method="post" action="">
    $static = "Select Size";
    if ($row_rsRings['size'] != "") {
    $myfields = $row_rsRings['size'];
    $myarray = explode(";", $myfields); ?>
    <select name="size">
    <?php if ($static != "") { ?>
    <option value="" selected="selected"><?php echo $static ?></option>
    <?php }
    for ($i=0; $i<sizeof($myarray); $i++) { ?>
    <option value="<?php echo $myarray[$i] ?>"<?php $i==0 && $static=="" ? print " selected" : print ""; ?>><?php echo $myarray[$i] ?></option>
    <?php } ?>
    <?php } else {
    echo "<input type=\"hidden\" name=\"size\">";
    } ?>

    Do I also need to make them hit a submit button, or can I tie that into the buy now button?

    Last edited by lozza; 09-03-2008 at 12:39 PM. Reason: Typo

  2. #2
    jthayne's Avatar

    Join Date
    Aug 2008

    Re: PHP Form menu: POST to same page problem

    This is the simplest way to do what you are asking.

    First, put every key/value piece either into the form as hidden values (if the user will not be editing the value) or add the string to the action value in the form tag. You also will want to change the method to get. That way all values will be posted to the URL rather than the $_POST superglobal.

    <form id="form1" name="form1" method="get" action="?merchant_id=0001">
    Also, change the name of the select tag to "product_size" as well as the name of your hidden input tag.

    <select name="product_size">
    That way, the value is declared properly in the URL.

    Use the Buy Now button as the submit button.

    <input type="image" src="images/buynow.gif" height="30" width="173" border="0" alt="Buy Now">

  3. #3
    lozza's Avatar
    New User

    Join Date
    Sep 2008

    Re: PHP Form menu: POST to same page problem

    THanks for your reply!

    I have managed to work it out - I posted it to same page and then made the selection into a variable that is then concatenated into a 3 part product ID number tath is sent to my shopping cart page.

    Silly me - I never even THOUGHT of making the 'submit' button the same as the Buy Now! Thanks a bunch for your post...seems to be working for the moment


Tags for this Thread