我希望我能得到一些帮助。当我尝试登录该系统时,我收到会话注册错误: *致命错误:在第 18 行的 C:\xampp\htdocs\check.php 中调用未定义的函数 session_register()* 顺便说一句,我刚刚开始学习 PHP所以我是那里的新手:)
有一个代码Register.php:
<?php
include('MySQL.php');
include('password.php');
$Username = $_POST['user'];
$Password = $_POST['password'];
$Re_Password = $_POST['password2'];
if($Username == "")
{
die("You don't enter a username!");
}
if($Password == "" || $Re_Password == "")
{
die("You didn't enter one of your passwords!");
}
if($Password != $Re_Password)
{
die("Your passwords don't match! Try again.");
}
$query = mysql_query("SELECT * FROM users WHERE username='$Username'");
if(mysql_num_rows($query) != 0)
{
echo "Username already exists";
}
else
{
$hash = password_hash($Password, PASSWORD_BCRYPT);
if (password_verify($Password, $hash)) {
if(!mysql_query("INSERT INTO users (username, password)
VALUES ('$Username', '$hash')"))
{
die("Connection problems!");
}
echo "<center>";
echo "Registration was successfull!<br>";
echo "Your user name: $Username<br>";
echo "<a href='login.php'>Login to the system</a>";
echo "</center>";
}
}
?>
检查.php:
<?php
ob_start();
include('MySQL.php');
$username=$_POST['user'];
$password=$_POST['password'];
$query = mysql_query ("SELECT * FROM users WHERE username='$username' AND password='$password'");
if(mysql_num_rows($query) == 1)
{
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("username");
session_register("password");
header("location:success.php");
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
?>