-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.php
62 lines (62 loc) · 1.95 KB
/
login.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
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
57
58
59
60
61
62
<?php
session_start();
if(isset($_SESSION['email'])):
header("location:homepage.php");
endif;
$msg='';
$error=false;
if (isset($_POST['email'])):
include "error.php";
include "classes/DBase.php";
include "classes/stmt.php";
$email=$_POST['email'];
$password=$_POST['password'];
$conn = new DBase("brokfree");
$pdo=$conn->pdo;
$s1=new Stmt($pdo);
$sql='SELECT password_hash,mobile from users where email=:email';
$arr=['email'=>$email];
$s1=$s1->run($sql,$arr);
if($s1->rowCount()==0):
$error=true;
$msg="Enter correct email";
else:
foreach ($s1 as $row) {
$p_hash=$row['password_hash'];
$mobile=$row['mobile'];
}
if(password_verify($password,$p_hash)):
session_start();
if(isset($_POST['ksi'])):
try{
$str=$email.$mobile;
$str=hash("sha512",$str);
setcookie('ksi',$str,time()+3600*24*365,'','',0,1);
$sql='INSERT INTO logged SET
email=:email,
hash=:hash';
$arr=[
'email'=>$email,
'hash'=>$str,
];
$s1= new Stmt($pdo);
$s1->run($sql,$arr);
}
catch(PDOException $e){
}
endif;
$_SESSION['email']=$email;
else:
$error=true;
$msg="Wrong Password";
endif;
endif;
if(!$error):
header("location: homepage.php");
endif;
endif;
ob_start();
include "../brokfree/templates/login.html.php";
$out= ob_get_clean();
echo $out;
?>