Jump to content

Only one script works at a time.................What Gives?


Modernvox

Recommended Posts

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>";

?>

 

 

 

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();

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.