在phpmyadmin中看不到表格内容

时间:2017-01-08 10:13:54

标签: php mysql phpmyadmin

我创建了一个数据库来保存我的用户信息。但我只能看到密码部分的内容,我看不到其他部分的内容,如电子邮件,用户名,名字等。我在这里放了一个截图,我的php代码谢谢大家。enter image description here

    <?php
session_start();

$db = mysqli_connect("localhost", "", "", "register_user");

if (isset($_POST["submit"])) {
    session_start();
    $firstname = mysql_real_escape_string($_POST["firstname"]);
    $lastname = mysql_real_escape_string($_POST["lastname"]);
    $username = mysql_real_escape_string($_POST["username"]);
    $password = mysql_real_escape_string($_POST["password"]);
    $password_2 = mysql_real_escape_string($_POST["password_2"]);
    $email = mysql_real_escape_string($_POST["email"]);
    $email_2 = mysql_real_escape_string($_POST["email_2"]);

    if ($password == $password_2) {

        $password = md5($password);
        $sql = "INSERT INTO user_data(firstname, lastname, username, password, email) VALUES('$firstname', '$lastname', '$username', '$password', '$email')";
        mysqli_query($db, $sql);
        $_SESSION['message'] = "You logged successfully";
        $_SESSION['username'] = $username;
        header("location: index.html");
    }else {
        $_SESSION['message'] = "Passwords don't match";
    }
}

?>

1 个答案:

答案 0 :(得分:0)

如果您使用的是mysqli,请使用

mysqli_real_escape_string(connection,escapestring);

希望它有所帮助。

另外,你不需要两次启动会话就可以使用它一次