bri0987 Posted October 21, 2007 Share Posted October 21, 2007 Hello again all. Shopping Cart for Custom PC configuration QUICK INFO... configuration.php >>> I have TWO buttons on my Form. 1.) Update Price 2.) Add to Cart Clicking on "Add to Cart" submits the FORM method POSTS to >>> cart.php I cant figure out how to make it so when I click the button "Update Price" ... I can get the FORM to POST back to the same page (configuration.php , not cart.php)... The reason for this is that I plan on grabing the $_POST["Selected_Prices"] data and uploading the price at the top of the page and next to the "Add to cart" button. Of course this is just for users to make their lives easier. Anyone have any help about this... Let me know. Quote Link to comment https://forums.phpfreaks.com/topic/74168-2-submit-buttons-in-one-form-hmmmmm/ Share on other sites More sharing options...
corillo181 Posted October 21, 2007 Share Posted October 21, 2007 add a if statement. if($_POST['submit']){ }elseif($_POST['update']){ } name the submit bottom submit and the update update. Quote Link to comment https://forums.phpfreaks.com/topic/74168-2-submit-buttons-in-one-form-hmmmmm/#findComment-374568 Share on other sites More sharing options...
bri0987 Posted October 21, 2007 Author Share Posted October 21, 2007 add a if statement. if($_POST['submit']){ }elseif($_POST['update']){ } name the submit bottom submit and the update update. But isn't the problem with this code that "No matter what button is clicked" both of them get submitted with the form. So if my 2 submit buttons (one name=submit , two name=update) they will still both send to the $_POST. ???? Quote Link to comment https://forums.phpfreaks.com/topic/74168-2-submit-buttons-in-one-form-hmmmmm/#findComment-374583 Share on other sites More sharing options...
corillo181 Posted October 21, 2007 Share Posted October 21, 2007 nope, you are giving each bottun a name so the code takes the bottun that have been pressed. here is a code so you can test. <?php if($_POST['submit']){ echo 'you have submited the form'; }elseif($_POST['update']){ echo 'the form have been update'; }else{ echo 'nothing has been done'; } ?> <form id="form1" name="form1" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <label>submit <input type="submit" name="submit" id="submit" value="Submit" /> </label> <br /> <label>update <input type="submit" name="update" id="update" value="update" /> </label> <br /> <label> nothing <input type="submit" name="nothing" id="nothing" value="nothing" /> </label> </form> Quote Link to comment https://forums.phpfreaks.com/topic/74168-2-submit-buttons-in-one-form-hmmmmm/#findComment-374585 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.