This commit is contained in:
2024-06-12 15:26:27 +02:00
parent 28af5705ee
commit 8851ff41b4
19 changed files with 331 additions and 20 deletions

31
php/login.php Normal file
View File

@@ -0,0 +1,31 @@
<?php
require 'connect.inc.php';
require 'core.inc.php';
if (isset($_POST['email']) && isset($_POST['password'])) {
$email = $_POST['email'];
$password = $_POST['password'];
$password_hash = md5($password);
if (!empty($email) && !empty($password)) {
$query = "SELECT `id` FROM `globaly_accounts` WHERE `email` ='" . mysqli_real_escape_string($con, $email) .
"' 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 email/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 email or password';
}
}
?>