-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsign_in_connect.php
57 lines (46 loc) · 1.51 KB
/
sign_in_connect.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
<?php
require 'config.php';
session_start();
if ($_SERVER["REQUEST_METHOD"] === "POST"){
$uid = $_POST["uid"];
$pwd = $_POST["pwd1"];
//check customer table
$sql = "SELECT * FROM customers WHERE email = '$uid' AND pasword = '$pwd'";
$result = $conn->query($sql);
//check administrater table
$sql1 = "SELECT * FROM administrator WHERE email = '$uid' AND pasword = '$pwd'";
$result1 = $conn->query($sql1);
//check author table
$sql2 = "SELECT * FROM author WHERE email = '$uid' AND pasword = '$pwd'";
$result2 = $conn->query($sql2);
if($result->num_rows > 0){
$_SESSION["usename"] = $uid;
header("Location:homepage.php");
}
elseif($result1->num_rows > 0){
$_SESSION["usename"] = $uid;
header("Location:Admin/admin.php");
}
elseif ($result2->num_rows > 0) {
$_SESSION["usename"] = $uid;
header("Location:author.php");
}
else{
echo "<script>alert('invalid credantial.'); window.location.href = 'sign_in.php';</script>";
}
}
else{
header("Location:homepage.php");
}
// $select = mysqli_query($conn, "SELECT * FROM usersaccounts WHERE email='$username' AND pasword = '$password'");
// $row = mysqli_fetch_array($select);
// if(is_array($row)){
// $_SESSION["username"] = $row['email'];
// $_SESSION["pass"] = $row['pasword'];
// }
// else{
// echo '<script> alert("invalid username or password")</script>';
// }
// if (isset($_SESSION["username"])){
// header("Location:welcome.php");
// }