Я использую php и ibm db2 для создания простой страницы входа. Однако код не дает желаемых результатов, как ожидалось.
Вот мой код:
if (isset($_POST['login'])) {
$username = ($_POST['username']);
$password = ($_POST['password']);
if (empty($username)) {
array_push($errors, "Username is required");
}
if (empty($password)) {
array_push($errors, "Password is required");
}
elseif (count($errors)==0) {
//$password = md5($password);
$query = "SELECT * FROM people WHERE username = '$username' AND password = '$password'";
$results = db2_exec($db, $query);
if (db2_num_rows($results)) {
$_SESSION['username'] = $username;
$_SESSION['success'] = "Logged in successfully";
//echo "<script type='text/javascript'>window.location.href = 'index.php';</script>";
header('Refresh: 0; URL=index.php', true, 301);
}else{
array_push($errors, "Wrong username/password combination, Please try again.");
}
}
}