对于学校,我们需要建立一个注册和登录页面,最终将您发送到home.php。
现在我正在使用的代码似乎已被弃用。
我将mysql_real_escape_string更改为mysqli_real_escape_string,但现在似乎需要参数。我有点失落,对此不熟悉。
我现在使用的代码是:
<?php
session_start();
// Retrieve username and password from database
$login = mysqli_query("SELECT * FROM gebruiker WHERE (username = '" . mysql_real_escape_string($_POST['username']) . "') and (password = '" . mysql_real_escape_string(md5($_POST['password'])) . "')");
$rolid = mysqli_query("SELECT * FROM gebruiker WHERE (rolid = " . $_SESSION['rolid'] . ")");
// Check username and passwords match
if(mysqli_num_rows(login) == 1) {
while($record = mysqli_fetch_array($login)) {
$_SESSION['rolid'] = $record['rolid'];
echo 'Je rol-ID is ' . $_SESSION['rolid'];
}
// Jump to secured page
header('location: home.php');
} else {
header('location: index.php');
}
?>