Click to See Complete Forum and Search --> : CMS delete problem


james19
03-14-2008, 04:07 AM
Im trying to make a content management system but cannot get this code to work. It works when I run just the PHP code like this:

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

mysql_select_db("rkhan19", $con);

mysql_query("DELETE FROM memory WHERE mem_ID='13'");

mysql_close($con);
?>

However, this does not work when I add a form onto it. The code is shown below:
<?php
$con = mysql_connect("localhost","rkhan19","Rash799");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("rkhan19", $con);

mysql_query("DELETE FROM memory WHERE mem_ID='13'");

mysql_close($con);
?>

Below is the form that I am using:
<table width="80%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#999999">
<tr>
<td bordercolor="#FFFFFF"><form name="form1" method="post" action="sdelete.php">
<p>&nbsp;mem_ID:
<input name="mem_ID" type="text" id="mem_ID">
</p>

<p align="center">
<input type="submit" name="Submit" value="Submit">
</p>

</form>
</td>
</tr>
</table>


You suggestions would be appreciated:)

james19
03-14-2008, 04:11 AM
Sorry on the second piece of code I have used this code on line 9:
mysql_query("DELETE FROM memory WHERE mem_ID='$mem_ID'");

Sorry about the mistake.

Sid3335
03-14-2008, 04:17 AM
Sorry on the second piece of code I have used this code on line 9:
mysql_query("DELETE FROM memory WHERE mem_ID='$mem_ID'");

Sorry about the mistake.

should be

mysql_query("DELETE FROM memory WHERE mem_ID='".$_POST['mem_ID']."'");

james19
03-14-2008, 04:31 AM
Should be

LOL :D
Thanks for the help and the speedy reply :)