Need Help with Deletion from mysql?

hey theree, I’m a complete newbie to all this php stuff as well as mysql; but I’ve gotten familiar with a few things including how deletion works. I’m creating a website for a project, unfortunately my deactivation won’t work. I’ve looked it over a million times but it simply won’t delete the information from my table in mysql. The code is below, help?

Username:
  Password: <input type="password" name="passworddel"  />
<input type="submit" name="submit2" value="Deactivate Account" /></form></table><br /></p>
<?php $con=mysql_connect("hostname","dbname","Password"); if(!$con){ die('Could not connect: ' . mysql_error()); } mysql_select_db("dbname", $con); if(isset($_POST['submit2'])){ $usernamedel=$_POST['usernamedel']; $passworddel=$_POST['passworddel']; mysql_query("DELETE FROM table WHERE username='$usernamedel' and password='$passworddel'"); mysql_close($con); echo "Your account has been deactivated $usernamedel"; } ?>

Hey mortifiedsmurf.

I hope that you’ve been able to figure out how to do this but, here’s how i would do it.

[php]
$query = ‘DELETE FROM table WHERE username = "’.$usernamedel.’" AND password = “’.$passworddel.’”’;
$result = mysql_query($query) or die(mysql_error());
mysql_close($con);
[/php]

If it doesnt work, try make a simple INSERT query, if that still doesnt work then you’ve got an issue with selecting your DB.

Thanks,

Dan

Thanks for the help, I figured it out! Ahahaa. : )

Thats cool :slight_smile: How did you do it in the end?

Sponsor our Newsletter | Privacy Policy | Terms of Service