与MySQL Insert命令相反

时间:2012-12-11 01:01:02

标签: php html mysql

MySQL INSERT命令的反义词是什么?

我想知道如何在没有管理员的情况下从表中删除用户。我用Google搜索,但根本找不到它。

这是我的PHP文件:

<?php
$username = $_POST["username"];
$password = $_POST["password"];
$passcheck = $_POST["passcheck"];
$email = $_POST["email"];
if ( $username && $password && $passcheck && $email ) {
} else
    echo "Please enter all fields";
?>
...
<form action="register.php" method="post">
    <input type="text" name="username"><br>
    <input type="password" name="password"><br>
    <input type="password" name="passcheck"><br>
    <input type="text" name="email"><br>
    <input type="submit" value="Register">
</form>
<?php
$username = $_POST["username"];
$password = $_POST["password"];
$passcheck = $_POST["passcheck"];
$email = $_POST["email"];
if ( $username && $password && $passcheck && $email ) {
    $connect = mysql_connect( "localhost", "root", "root" ) or die("Couldn't connect!");
    mysql_select_db("login") or die("Couldn't find database!");
    $query = mysql_query( "SELECT * FROM users WHERE username='$username'" );
    $numrows = mysql_num_rows( $query );
        if ( $numrows != 0 ) {
        echo "Username taken";
    } else
        if ( $password == $passcheck ) {
            mysql_query("INSERT INTO users (username, password, email)
                VALUES ('$username','$password','$email')");
        } else
            echo "Passwords don't match";
} else
    echo "Please enter all fields";
?>

2 个答案:

答案 0 :(得分:4)

MySQL Delete语句是:

DELETE FROM table_name WHERE some_column = some_value;

看看这里:http://www.w3schools.com/php/php_mysql_delete.asp

答案 1 :(得分:1)

DELETE FROM some_table WHERE some_value = X;