Modernvox Posted August 26, 2010 Share Posted August 26, 2010 I have the following 2 scripts. One adds to the database and the other deletes a record from the database. <form action="deletebidder.php" method="post"> <table> <tr> <td><font face ="calibri" size="4"> Add Bidder:</td> </tr> <tr> <td><input type="text" name="biddersId" /></td> </tr> <tr> <td><input type="hidden" name="addedbidder" /></td> </tr> <tr> <td><input type="Submit" value="Add"></td> </tr> </table> Second from: <form name="deletebidder" action="process_bidders2.php" method="post"> <table> <tr> <td><font face= "calibri" size= "3"> Delete Bidder</font></td> </tr> <tr> <td><input type= "text" name="deletebidder" /></td> </tr> <tr> <td><input type= "hidden" name="deletebidder1" /></td> </tr> <tr> <td><input type= "submit" value= "submit" /></td> </tr> </table> </form> Both forms are on the same page. Now I have tried separate processing pages with the same results (If i get one to work the other doesn't, it's either one or the other, but they won't work together. If i have the add bidder working, the delete bidder doesn't work and visa versa?? Also, ONE IMPORTANT note is, if i try to process each form on separate pages, no matter what action "name" i give the form, it will only go to the action page that is working. Example is, I tried to process one form on deletebidder.php and the other on process_bidders2.php but it didn't matter. Both forms were processed by the deletebidder.php page. How is this even possible if I gave them both seperate action "paths"?? <?php ob_start(); error_reporting(E_ALL); ini_set("display_errors", 1); $biddersId= $_POST['biddersId']; if (isset($addedbidder)) \\hidden form field { mysql_connect("$host", "$db_user", "$db_password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM bidders WHERE biddersId='$biddersId'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); if($count==0){ // Add $biddersId to DB and redirect to anypage mysql_Query("INSERT INTO bidders (biddersId) VALUES ('$biddersId')"); header("Location: attendance.php"); exit(); } } if (isset($deletebidder1)) \\hidden form field { $biddersId= $deletebidder; mysql_connect("$host", "$db_user", "$db_password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); mysql_query("DELETE FROM bidders WHERE biddersId='$biddersId'"); header("Location: attendance.php"); exit(); } ob_flush(); echo "<font color= \"red\" face=\"calibri\" size=\"4\">That bidder is already logged, Please press your browsers back button and try again.</font>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/211759-only-one-script-works-at-a-timewhat-gives/ Share on other sites More sharing options...
nethnet Posted August 26, 2010 Share Posted August 26, 2010 Do you have a closing tag for your first form? Quote Link to comment https://forums.phpfreaks.com/topic/211759-only-one-script-works-at-a-timewhat-gives/#findComment-1103816 Share on other sites More sharing options...
Modernvox Posted August 26, 2010 Author Share Posted August 26, 2010 Do you have a closing tag for your first form? Yes, I tried it with the closing tag as well Quote Link to comment https://forums.phpfreaks.com/topic/211759-only-one-script-works-at-a-timewhat-gives/#findComment-1104169 Share on other sites More sharing options...
harristweed Posted August 26, 2010 Share Posted August 26, 2010 echo what's being received from the posted forms, that will point you in the right direction. Quote Link to comment https://forums.phpfreaks.com/topic/211759-only-one-script-works-at-a-timewhat-gives/#findComment-1104174 Share on other sites More sharing options...
Modernvox Posted August 26, 2010 Author Share Posted August 26, 2010 echo what's being received from the posted forms, that will point you in the right direction. Just echo the variables? Quote Link to comment https://forums.phpfreaks.com/topic/211759-only-one-script-works-at-a-timewhat-gives/#findComment-1104178 Share on other sites More sharing options...
Modernvox Posted August 26, 2010 Author Share Posted August 26, 2010 Am I suppose to be naming both my forms, is that the problem? If so, how do i refer to them to process?? Quote Link to comment https://forums.phpfreaks.com/topic/211759-only-one-script-works-at-a-timewhat-gives/#findComment-1104183 Share on other sites More sharing options...
Modernvox Posted August 26, 2010 Author Share Posted August 26, 2010 Ok...To everyone who lookked and couldn't figure this out.... I did. Here's the proper code: $biddersId = $_POST['biddersId']; $deletebidder1= $_POST['deletebidder1']; $deletebidder = $_POST['deletebidder']; if ($_POST['deletebidder']) { $biddersId= $deletebidder; mysql_connect("$host", "$db_user", "$db_password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); mysql_query("DELETE FROM bidders WHERE biddersId='$biddersId'"); header("Location: attendance.php"); exit(); } if ($_POST['biddersId']) { mysql_connect("$host", "$db_user", "$db_password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM bidders WHERE biddersId='$biddersId'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==0){ // Add $biddersId and redirect to anypage mysql_Query("INSERT INTO bidders (biddersId) VALUES ('$biddersId')"); header("Location: attendance.php"); exit(); } } else { echo "<font color= \"red\" face=\"calibri\" size=\"4\">That bidder is already logged, Please press your browsers back button and try again.</font>"; } ob_end_flush(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/211759-only-one-script-works-at-a-timewhat-gives/#findComment-1104189 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.