如何从MySQL数据库中删除一个用户,一旦他们已经验证了自己的电子邮件


How to remove a user from a MySQL Database once they have verified themselfs with there email

我需要一些MySQL数据库的帮助。我需要有一个功能,用户可以通过输入那里的电子邮件地址从数据库中删除自己,然后它会问他们,如果他们是100%肯定他们要删除自己,然后它会从数据库中删除他们。任何帮助将非常感激!

这是显示数据库上当前用户的页面- http://www.ironicwhiplash.com/join/members.php

EDIT我不是说我想让别人帮我写代码!很抱歉,如果它遇到的方式,因为它是清晨,我正试图得到这个从明天开始,因为我说它会完成!谢谢Joao提供的非常有用的答案!

EDIT 2我使用Joao前面提到的帖子中的代码制作了代码。下面是它使用的最终代码:)希望它能帮助到一些人。

我用了一个页面,用户输入了电子邮件地址:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Leave</title>
</head>

<body>
<form action="remove.php" method="post">
<label style="color:#000">Email:</label><br/>
<input name="email" type="email" required="required" style="color:#000">   <br/>
<input type="submit" value="Leave" class="btn btn-danger">
</form>
</body>
</html>

然后我有另一个文件叫做'remove.php':

<?php
$host="localhost"; // Host name 
$username="username"; // Mysql username 
$password="password"; // Mysql password 
$db_name="database name"; // Database name 
$tbl_name="tablename"; // Table name 
// Connect to server.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
$email=$_POST['email']; //Fetch the email address from the last page and set it     as a variable called '$ email'
$sql="DELETE FROM $tbl_name
WHERE email='$email'"; //Delete the user where the email address is the same     as the one which they put in the last form
$result=mysql_query($sql); //Find the result of the executed code
if($result){
echo "Successfully Removed"; //Tell the user if it was removed successfully
}
else {
echo "ERROR"; //Tell you if there is a error.
}
mysql_close(); //Close your SQL connection
?>

查理:)

不确定我是否正确理解了你的问题。我想你只是想做一个delete from MySQL命令。

DELETE FROM table_name
WHERE some_column=some_value;