-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.php
51 lines (45 loc) · 1.54 KB
/
log.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
<?php
session_start();
include('lib/dbh.php');
if ($_SERVER["REQUEST_METHOD"] == "POST") {
function check_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$email=check_input($_POST['email']);
$password=md5(check_input($_POST['password']));
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$_SESSION['log_msg'] = "Invalid email format";
header('location:login.php');
}
else{
$query=mysqli_query($conn,"select * from clients where email='$email' and password='$password'");
if(mysqli_num_rows($query)==0){
$_SESSION['log_msg'] = "Client not found or Wrong password";
header('location:login.php');
}
else{
$row=mysqli_fetch_array($query);
if($row['verify']==0){
$_SESSION['log_msg'] = "Client not verified. Please activate account";
header('location:login.php');
}
else{
$_SESSION['user_id']=$row['id'];
$_SESSION['user_firstname']=$row['firstname'];
$_SESSION['user_middlename']=$row['middlename'];
$_SESSION['user_lastname']=$row['lastname'];
$_SESSION['user_gender']=$row['gender'];
$_SESSION['user_contact']=$row['contact'];
$_SESSION['user_county']=$row['county'];
$_SESSION['user_email']=$row['email'];
$uip=$_SERVER['REMOTE_ADDR'];
$uid=$row['email'];
$log =mysqli_query($conn,"INSERT INTO clientLog (client,ip)VALUES('$uid','$uip')");
header('location:index.php?page=home');
}
}
}
}