erok Posted September 3, 2012 Share Posted September 3, 2012 Hi everyone,If it is possible to use same form for more than one button such as delete , update and insert to/from phpmy admin.I want to use one form and three button under the same form.Any direction appreciatedErok Link to comment Share on other sites More sharing options...
birbal Posted September 3, 2012 Share Posted September 3, 2012 yes it is possible you have to use different value for each button.when you submit the form you need to check the button value inside $_GET or $_POST array depending upon the form submit method. depending upon the value you can take different action. Link to comment Share on other sites More sharing options...
Don E Posted September 3, 2012 Share Posted September 3, 2012 (edited) Thanks kanchatchai. Edited September 4, 2012 by Don E 1 Link to comment Share on other sites More sharing options...
kanchatchai Posted September 4, 2012 Share Posted September 4, 2012 <form id="form1" name="form1" method="post" action=""> <input type="submit" name="buttonAdd" id="buttonAdd" value="Add" /> <input type="submit" name="buttonUpdate" id="buttonUpdate" value="Update" /> <input type="submit" name="buttonDelete" id="buttonDelete" value="Delete" /></form><?PHP if (isset($_POST['buttonAdd'])) {echo('Add');} if (isset($_POST['buttonUpdate'])) {echo('Update');} if (isset($_POST['buttonDelete'])) {echo('Delete');}?>[/Code] Link to comment Share on other sites More sharing options...
erok Posted September 4, 2012 Author Share Posted September 4, 2012 I tried this. It did not run.Any suggestion appreciated<form method="post" action="<?php if (isset($_POST['formupdate'])) { echo 'yenileyerel.php' } if (isset($_POST['formdelete'])) { echo 'silyerel.php' } if (isset($_POST['forminsert'])) { echo 'ekleyerel2.php' } ?> " >First name:<input type="text" name="firstname" size="30" maxlenght="30" /><br /><br />Last name:<input type="text" name="lastname" size="30" maxlenght="30" /><br /><br />Phone number:<input type="text" name="phone" size="30" maxlenght="30" /><br /><br /><input type="submit" name="formupdate" id="formupdate" value="Update" size="25" /><input type="submit" name="formdelete" id="formdelete "value="Delete" size="25" /><input type="submit" name="forminsert" id="forminsert" value="Insert" size="25" /></form></body> Link to comment Share on other sites More sharing options...
justsomeguy Posted September 4, 2012 Share Posted September 4, 2012 You're missing semicolons on each echo statement. If you're not seeing those errors then you have error reporting disabled, you'll want to turn that on while you're testing things. Link to comment Share on other sites More sharing options...
erok Posted September 4, 2012 Author Share Posted September 4, 2012 Sorry about that, It is at this copy. In original file I have semicolons. Still it did not run.Actually i see error 403 when i try to run program Link to comment Share on other sites More sharing options...
justsomeguy Posted September 4, 2012 Share Posted September 4, 2012 A 403 response is a permission problem, not a problem with the code. A PHP error would normally cause the server to generate a 500 response. http://en.wikipedia.org/wiki/HTTP_403 Link to comment Share on other sites More sharing options...
Net123 Posted September 5, 2012 Share Posted September 5, 2012 but the 500 internal server error would happen @ when we sending wrong parameter to the server right ?i think you better to see your error_log file for investigate about this error... Link to comment Share on other sites More sharing options...
erok Posted September 6, 2012 Author Share Posted September 6, 2012 It was html file instead of php file. That is why it showed error 403. I switched it to php file, when i submited the form this time it took me to localhost xampp index page.It did not parse php Link to comment Share on other sites More sharing options...
justsomeguy Posted September 6, 2012 Share Posted September 6, 2012 If you're still using the code in post 5, that code does not change where the form is submitted based on which button was pressed. When that code runs the form hasn't been submitted yet, so none of those values that you're checking for in $_POST exist. They only exist once the form is submitted. You should submit that form to a single script that determines which button was pressed and takes the appropriate actions. Link to comment Share on other sites More sharing options...
erok Posted September 6, 2012 Author Share Posted September 6, 2012 Thank you all who inspiring and helping me out,Program is running now. One form control three seperate buttons.All i needed to do is combining three sepererate files update, delete and insert into a file and using it as ( action="unitedkitchen.php" ) in the form code." Just some guy " tutorial is especially helpful.erok Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now