如何将我的数据正确插入数据库表?我在php中的条件为“成功”,但我的数据库表仍然为空

时间:2019-02-08 11:55:00

标签: php mysql

它说我的标题位置成功了,但是我的问题是我的数据库表仍然为空。

我在我的register.php中填写了表格。我的标题位置显示“ SUCCESS”,但是当我检查数据库表仍然为空时。我下面的代码怎么了?

<?php
     $servername = "localhost";
     $username = "root";
     $password = "";
     $dbname = "student-information";

    $conn = mysqli_connect($servername, $username, $password, $dbname);

    //registration
  if (isset($_POST['register-btn'])) {
$fname = mysqli_real_escape_string($conn, $_POST['fname']);
$lname = mysqli_real_escape_string($conn, $_POST['lname']);
$uname = mysqli_real_escape_string($conn, $_POST['uname']);
$pwd = mysqli_real_escape_string($conn, $_POST['pwd']);
if (empty($fname) || empty($lname) || empty($uname) || empty($pwd)) {
    header("Location: admin-register.php?=some-Field-Empty");
    exit();
}
else {
       $sql = "INSERT INTO admin (firstname, lastname, username, password)
    VALUES ('$fname', '$lname', '$uname', $pwd);";
    mysqli_query($conn, $sql);
    header("Location: admin-register.php=SUCCESS");
    exit();
    }
  }

0 个答案:

没有答案