-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex-ajax.php
More file actions
56 lines (52 loc) · 1.46 KB
/
Copy pathindex-ajax.php
File metadata and controls
56 lines (52 loc) · 1.46 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
session_start();
require_once 'class.user.php';
$user_home = new USER();
if(isset($_POST['btn-login']))
{
// if admin is checked
if(isset($_POST['isAdmin'])){
$user_email = trim($_POST['user_email']);
$user_password = trim($_POST['password']);
$password = md5($user_password);
try{
$stmt = $user_home->runQuery("SELECT * FROM tbl_admin WHERE email=:email");
$stmt->execute(array(":email"=>$user_email));
$userRow = $stmt->fetch(PDO::FETCH_ASSOC);
$count = $stmt->rowCount();
if($userRow['userPass']==$password){
echo "admin-ok"; // log in
$_SESSION['userSession'] = $userRow['adminId'];
return true;
}
else{
echo "Admin Email and or Password is incorrect."; // wrong details
}
}
catch(PDOException $e){
echo $e->getMessage();
}
}else{
$user_email = trim($_POST['user_email']);
$user_password = trim($_POST['password']);
$password = md5($user_password);
try{
$stmt = $user_home->runQuery("SELECT * FROM tbl_mothers WHERE email=:email");
$stmt->execute(array(":email"=>$user_email));
$userRow = $stmt->fetch(PDO::FETCH_ASSOC);
$count = $stmt->rowCount();
if($userRow['userPass']==$password){
echo "ok"; // log in
$_SESSION['userSession'] = $userRow['idNumber'];
return true;
}
else{
echo "Email and or Password is incorrect."; // wrong details
}
}
catch(PDOException $e){
echo $e->getMessage();
}
}
}
?>