simple MYSQL help. delete from a html form

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
luke_barnes
Forum Newbie
Posts: 6
Joined: Thu Apr 09, 2009 6:45 pm

simple MYSQL help. delete from a html form

Post by luke_barnes »

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.
tech603
Forum Commoner
Posts: 84
Joined: Thu Mar 19, 2009 12:27 am

Re: simple MYSQL help. delete from a html form

Post by tech603 »

mysql_query("DELETE FROM mailinglist WHERE email=''");
I'm confused on whether or not your meant the above code to be true. Are you looking to delete from the mailing list where emails are null? Because i would assume it being a mailing list you wouldn't have null values, so in that case you would want to change your where clause to have the correct email address you are looking to remove.

hope that helps
Post Reply