註冊人員時出現問題。我已經嘗試登錄,它完美的工作。未將數據插入到XAMPP數據庫中
腳本數據庫
CREATE TABLE userinfor ( userid INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(25) NOT NULL, password VARCHAR(15) NOT NULL, email VARCHAR(35) NOT NULL );
PHP代碼
$emailErr = $passMismatch = "";
if(isset($_POST['submit'])){
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_REQUEST['name'];
$pwd = $_REQUEST['password'];
$cpwd = $_REQUEST['cpassword'];
$email = $_REQUEST['email'];
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "ERROR::Invalid E-Mail Format";
} else $emailErr = "";
if ($pwd != $cpwd) {
$passMismatch = "ERROR::Passwords Don't Match";
} else $passMismatch = "";
$host = "localhost";
$username = "root";
$password = "";
$database = "ontheway";
$conn = mysqli_connect($host, $username, $password, $database);
if (empty($emailErr) && empty($passMismatch)) {
$sql = "INSERT INTO userinfo (userid, name, password, email)
VALUES (NULL, $name', $pwd', '$email')";
$result = mysqli_query($conn, $sql);
if (!$result) {
echo "chala nahi query";
}
if ($result) {
session_start();
$_SESSION['name'] = $name;
$_SESSION['pass'] = $pass;
header("location: home.php");
}
}
}
}
我想呼應的問題,但我無法找到任何,$名稱,$ PWD,$ CPWD,$電子郵件都得到迴應。即使這些錯誤也正在完美地顯示在表格上。數據庫也正在連接。什麼似乎是問題?請幫助:)
我總是得到「chala nahi查詢」,這意味着查詢SQL不會工作,每次我運行這個。
表單代碼
名稱:
<input type="text" name="name" /> <br />
<p>Password: </p>
<input type="password" name="password" /> <br />
<?php echo '<h1>'.$passMismatch.'</h1>'; ?>
<p>Confirm Password: </p>
<input type="password" name="cpassword" /> <br />
<p>Email: </p>
<input type="email" name="email" /> <br />
<?php echo '<h1>'.$emailErr.'</h1>'; ?>
<input type="submit" name="submit" />
耶第一,我沒有插入的用戶ID,但由於它不工作我想也許這可能是問題。隊友的歡呼聲 :) –