-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsession.php
42 lines (35 loc) · 876 Bytes
/
session.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
<?php
session_start();
$db_host = "localhost";
$db_username = "root";
$db_pass = "";
$db_name = "event";
$con = mysqli_connect("$db_host","$db_username","$db_pass","$db_name");
if(isset($_POST['login'])){
$email = $_POST['email'];
$pass = $_POST['pass'];
$gt=0;
$ddf = mysqli_query($con, "SELECT id,name,email,qstn,pass FROM entry WHERE email='$email'");
{
//if($ddf) echo "yes"; else echo "no";
while($r = mysqli_fetch_array($ddf)){
$aid=$r['id'];
$pss=$r['pass'];
$qstn=$r['qstn'];
$gt=1;
if($pass==$pss){
$_SESSION['user'] = $aid;
$date=date('y-m-d H:i:s');
header('Location: '.$qstn.'.php');}
else {header('Location: index.php');}
}
}
if($gt==0) header('Location: index.php');
}
if(isset($_SESSION['user'])){
$aid=$_SESSION['user'];
}
if(isset($_POST['logout'])){
session_destroy();
header('Location: index.php');}
?>