-
Notifications
You must be signed in to change notification settings - Fork 0
/
signin.php
31 lines (28 loc) · 1.07 KB
/
signin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
ini_set('session.save_path', getcwd() . '\sessions');
session_start();
include 'db_connect.php';
$nick = $_POST['nick'];
$pwd = md5($_POST['pwd']);
$check_user = mysqli_query($link, "SELECT * FROM users WHERE (email = '$nick' OR nick = '$nick') AND u_password = '$pwd'");
if ($nick == "" || $pwd == "") {
$_SESSION['message'] = 'Всі поля повинно бути заповнено!';
header('Location: login.php');
} else {
if (mysqli_num_rows($check_user) > 0) {
$user = mysqli_fetch_assoc($check_user);
$_SESSION['id_user'] = $user['id_user'];
$_SESSION['nick'] = $user['nick'];
$_SESSION['email'] = $user['email'];
$_SESSION['age'] = $user['age'];
$_SESSION['u_status'] = $user['u_status'];
$_SESSION['about_user'] = $user['about_user'];
$_SESSION['u_password'] = $user['u_password'];
$_SESSION['avatar'] = $user['avatar'];
header('Location: index.php');
} else {
$_SESSION['message'] = 'Невірно введено логін або пароль!';
header('Location: login.php');
}
}
?>