Results 1 to 3 of 3
Related
-
required form fields in php page using redirect.php form Forum: PHP Forum
Replies: 1 -
Help please: Creating a link in a form list/menu Forum: HTML Forum
Replies: 3 -
Form drop down menu tool tips? Forum: CSS Forum
Replies: 0 -
Problem with form in IE6 - empty space at end of form Forum: HTML Forum
Replies: 1 -
Getting a blank page while returning from page with form Forum: PHP Forum
Replies: 2
-
09-03-2008, 12:17 PM #1
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="">
Size
<?php
$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 } ?>
</select>
<?php } else {
echo "<input type=\"hidden\" name=\"size\">";
} ?>
</form>
Do I also need to make them hit a submit button, or can I tie that into the buy now button?
THanksLast edited by lozza; 09-03-2008 at 12:39 PM. Reason: Typo
-
09-04-2008, 12:44 PM #2
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.
i.e.Code:<form id="form1" name="form1" method="get" action="?merchant_id=0001">
Code:<select name="product_size">
Use the Buy Now button as the submit button.
Code:<input type="image" src="images/buynow.gif" height="30" width="173" border="0" alt="Buy Now">
-
09-04-2008, 02:47 PM #3
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
Cheers.
Cloudjiffy- PaaS for Developers
10-05-2020, 12:30 AM in Web Hosting Forum