source: validateLogIn.php@ e3d4e0a

Last change on this file since e3d4e0a was e3d4e0a, checked in by Vlado 222039 <vlado.popovski@…>, 7 days ago

Upload project files

  • Property mode set to 100644
File size: 856 bytes
RevLine 
[e3d4e0a]1<?php
2
3 session_start();
4
5 if(empty($_POST['email']) || empty($_POST['password']))
6 {
7 header("Location: /Log In.php");
8 exit();
9 }
10
11 require 'connect.php';
12
13 $res = $conn->query('SELECT * FROM Users WHERE email="'.$_POST['email'].'";');
14
15 if($res->num_rows <= 0)
16 {
17 header("Location: /Log In.php?error=INVALID_EMAIL");
18 exit();
19 }
20
21 $res = $res->fetch_assoc();
22 $pswd = $res['password'];
23
24 if($_POST['password'] != $pswd)
25 {
26 header("Location: /Log In.php?error=INVALID_PASSWORD");
27 exit();
28
29 }
30
31 $_SESSION['email'] = $_POST['email'];
32 $_SESSION['user_ID'] = $res['user_ID'];
33 $_SESSION['is_admin'] = $res['is_admin'];
34 if($res['is_admin']) {
35 header("Location: ./AdminDashboard.php");
36 }
37 else {
38 header("Location: ./Home.php");
39 }
40?>
Note: See TracBrowser for help on using the repository browser.