我有一个注册页面,它将注册数据插入数据库。它遵循以下原则:
if ($_POST['password'] == $_POST['conf_pass']){
$user = $_POST['username'];
$pass = $_POST['password'];
$hash = md5(rand(0,1000));
$accres = mysqli_query($connection, "INSERT INTO accounts (street1, suburb, city, postcode, username) VALUES($address, $suburb, $city, $postcode, $username)");
$account_id = mysqli_insert_id($accres);
$peopleres = mysqli_query($connection, "INSERT INTO people (lastname, firstname, accounts_id, birthdate, phonenumber, username, password, email, hash) VALUES($lastname, $firstname, $account_id, $birthdate, $phonenumber, $username, $password, $email, $hash)");
$peoplerows=mysqli_fetch_assoc($peopleres);
$person_id=$peoplerows[0];
mysqli_query("INSERT INTO PeopleToRole (role_id) VALUES(1)");
$email = $_SESSION['email'];
$p->addContent("User Registered");
}
我最初使用 postgres 对所有这些进行了编程(同时在 apache 服务器上本地托管),但不得不更改为 mysqli,因为主机网站已经在使用 mysqli。
因此,此代码返回页面上的用户注册,因此 if 语句有效。但由于某种原因,插入语句不会向数据库中插入任何内容。
我有某种格式错误吗?还是我错过的小东西?任何和所有的帮助将不胜感激。谢谢