PHP,phpMyAdmin不显示任何查询结果

时间:2015-09-23 18:31:16

标签: php mysql

我在signup.php中有一段代码

    <head>
        <title>--:: Register ::--</title>
    </head>

    <body style="background: url(1799908.jpg);">
        <h1>
            <font color="white">Registration Form<br></font>
        </h1>
    </body>

<?php

    require('config.php');

    if(isset($_POST['submit']))
        {
            //Varification
            $pass1 = $_POST["psw1"];
            $pass2 = $_POST["psw2"];

            if ($pass1 == $pass2)
                {
                    $username = mysqli_escape_string($link, "username");
                    $pass1 = mysqli_escape_string($link, $pass1);
                    $pass2 = mysqli_escape_string($link, $pass2);
                    $fname = mysqli_escape_string($link, "fname");
                    $lname = mysqli_escape_string($link, "lname");
                    $email = mysqli_escape_string($link, "email");
                    $sex = mysqli_escape_string($link, "sex");
                    $birthday = mysqli_escape_string($link, "bday");

                    $pass1 = md5($pass1);

                    $result = mysqli_query($link, "SELECT * FROM 'DB_TABLE' WHERE username = '$username'");

                    $sql = "INSERT INTO `DB_TABLE` (username, psw, firstname, lastname, email, sex, bday)
                    VALUES ('$username', '$pass1', '$fname', '$lname', '$email', '$sex', '$birthday')";

                    mysqli_query($link, $sql);
                }
            else
                {
                    echo "Password mismatch";
                }
        }
    else
        {
$form = <<<EOT
<form action="signup.php" method="POST">
            <fieldset>
                <legend><font color="white">Login:</font></legend>
                    <font color="white">Username:</font>
                    <input type="text" name="username" required><font color="red">*</font>
                    <br><br>
                    <font color="white">Password:</font>
                    <input type="password" name="psw1" required><font color="red">*</font>
                    <br><br>
                    <font color="white">Re-Type Password:</font>
                    <input type="password" name="psw2" required><font color="red">*</font>
            </fieldset>

            <fieldset>
                <legend><font color="white">Personal Information:</font></legend>
                    <font color="white">First Name:</font>
                    <input type="text" name="firstname">
                    <br><br>
                    <font color="white">Last Name:</font>
                    <input type="text" name="lastname">
                    <br><br>
                    <font color="white">Email Address:</font>
                    <input type="text" name="email" required><font color="red">*</font>
                    <br><br>
                    <font color="white">Sex: <br>
                    <input type="radio" name="sex" value="male" checked>Male
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="radio" name="sex" value="female">Female</font>
                    <br><br>
                    <font color="white">Birthday:</font>
                    <input type="calendar" name="bday" required> <font color="red">*</font>

            </fieldset>

            <fieldset>
                <legend><font color="white">Security:</font></legend>


            </fieldset>
            <input type="submit" value="Register" name="submit">
            </form>
EOT;

            echo $form;
        }
?>

和config.php

<?php

/* Database function */
define ('DB_NAME', "register");
define ('DB_USER', "root");
define ('DB_PASSWORD', "");
define ('DB_HOST', "localhost");
define ('DB_TABLE', "users");

/* Connect to database */
$link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD);

/* Checking connection to database */
if (!$link)
    {
        die ('Could not connect:'. mysqli_error());
    }

/* Selecting table from database */
$db_selected = mysqli_select_db ($link, DB_NAME);

/* Checking connection to selected database */
if (!$db_selected)
    {
        die('can\'t use'. DB_NAME.':'. mysqli_error());
    }

/* If connection to database no problem */
else
    {
        echo "You good to go";
    }
?>

没有任何错误返回。但是当我填写表单并提交它时,查询结果甚至没有进入phpMyAdmin

我的查询文件保持为0,没有任何结果。

我使用XAMPP

0 个答案:

没有答案