Add exams from exam100 to exam150

This commit is contained in:
2024-05-13 08:50:26 +02:00
parent 4fd956ddac
commit 56492d171c
13 changed files with 366 additions and 0 deletions

37
exam135/loginform.inc.php Normal file
View File

@@ -0,0 +1,37 @@
<?php
if (isset($_POST['username']) && isset($_POST['password'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$password_hash = md5($password);
if (!empty($username) && !empty($password)) {
$query = "SELECT `id` FROM `users` WHERE `username` ='" . mysqli_real_escape_string($con, $username) .
"' AND `password` = '" .mysqli_real_escape_string($con, $password_hash )."'";
if ($query_run = mysqli_query($con, $query)) {
$query_num_rows = mysqli_num_rows($query_run);
if ($query_num_rows == 0) {
echo 'invalid username/password combination';
} else if ($query_num_rows == 1) {
//treba nam $user_id
$row = mysqli_fetch_assoc($query_run);
$user_id = $row['id'];
$_SESSION['user_id'] = $user_id;
header('Location: index.php');
}
} else {
}
} else {
echo 'You must suply username or password';
}
}
?>
<form action="<?php $current_file; ?>" method="POST">
Username: <input type="text" name="username"> Password: <input type="password" name="password">
<input type="submit" value="Submit">
</form>