Jump to content

form connect to mysql


erok

Recommended Posts

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

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

<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

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

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...