Jump to content

[SOLVED] delete record dependant upon conditon met


joshgarrod

Recommended Posts

i have a system where people can submit adverts and when they do so they also enter a password, so if their item is sold they can view their advert and enter their password into a form on it and if they match up delete the record. At the moment i am seeing the url in address bar but the page comes up blank when you submit the password.

 

Advert view with delete form:

<?php
$password = $info ['password'];
							$ref = $info ['ref'];
							echo "<h2>Is this your item, and has it been sold?</h2>";
							echo "<p>Simply type the password you entered when submitting the item and it will be removed from our website instantly.</p>";
							echo "<form method=\"POST\" action=\"delete_item.php?ref=".$info['ref']."\">
							Password: <input type=\"text\" name=\"password_entered\" size=10>
							<input name=\"hidden_password\" type=\"hidden\" value=\"$password\" />
							<input name=\"id_delete\" type=\"hidden\" value=\"$ref\" />
							<input type=\"submit\" value=\"Sold\">
							</form>";
?>

 

delete item:

<?php
$con = mysql_connect("serv","usr","pass");
		if (!$con)
			{
			  die('Could not connect: ' . mysql_error());
			 }

			mysql_select_db("db", $con);

$id=$_GET['id_delete'];
$password_entered = $_GET['password_entered'];
$hidden_password = $_GET['hidden_password'];

if ($password_entered == $hidden_password)
{

mysql_query("delete from classifieds where ref='$id'");

mysql_close(); 

header("location:thankyou.html"); 
}
else
{
echo "You entered the wrong password";
}
?>

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.