这是我的代码的结果,请给我帮助

时间:2019-12-25 18:51:09

标签: php mysqli

注意:未定义的变量:第11行的C:\ Users \ User \ Desktop \ xampp(1)\ htdocs \ website \ register.php中的conn

警告:mysqli_query()期望参数1为mysqli,在第11行的C:\ Users \ User \ Desktop \ xampp(1)\ htdocs \ website \ register.php中给出空值
* // 用于config.php //

<?php
$server = 'localhost';
$user = 'root';
$pass = '';
$db = 'system';

$conn = mysqli_connect($server,$user,$pass) or die ("error");

$selectdb = mysqli_select_db($conn,$db) or die("error");

?>

//*for register.php*//

<?php
include 'config.php';

if (isset($_POST["u_btn"])){
    $u_name = $_POST["u_name"];
    $u_email = $_POST["u_email"];
    $u_pass = $_POST["u_pass"];
    if (empty($u_name) || empty($u_email) || empty($u_pass)){
        echo "please complete all fields";
    }else{
        $insert = mysqli_query($conn,"INSERT INTO `users` (`u_name`, `u_email`, `u_pass`) VALUES (NULL, '$u_name', '$u_email', '$u_pass')");
        echo "success";
    }
}

?>
<form action="register.php" method="POST">
<label>Name</label>
<input type="text" name="u_name" value=""><br />
<label>Email</label>
<input type="text" name="u_email" value=""><br />
<label>password</label>
<input type="password" name="u_pass" value=""><br />

<input type="submit" name="u_btn" value="sign up"><br />

</form>*

0 个答案:

没有答案