Jump to content

simple HTML form delete from mysql database


luke_barnes

Recommended Posts

i have a very simple form that adds to a mailing list database now i need to delete from that databass with a similar form, strangely finding this hard.

 

here is the form:

<html>

<body>

<form action="delete1.php" method="post">

 

Email: </br>

<input type="text" name="email" /> </br>

<input type="submit" name="submit" />

</form>

</body>

</html>

 

this is simple stuff that i can delete from my database from, however iv been trying a few things to link the two.

 

<?php

$con = mysql_connect("localhost","root","");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}

mysql_select_db("slumtramp", $con);

 

mysql_query("DELETE FROM mailinglist WHERE email=''");

mysql_close($con);

?>

 

i'm sure this is a simple as hell fix but im stumped. any help would be great. thanks.

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("slumtramp", $con);
$email = mysql_real_escape_string($_POST['email']);
mysql_query("DELETE FROM mailinglist WHERE email='$email'");
mysql_close($con);
?>

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.