-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
36 lines (36 loc) · 1.03 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
<?php
include_once "config.php";
$host = $constring;
$username = $uname;
$password = $pword;
try {
$pdo = new PDO($host, $username, $password);
$username = $_POST["username"];
$password = $_POST["password"];
$mysql_password = $password;
$password = hash("sha256", $password);
$q = "SELECT password FROM users WHERE username = '" . $username . "'";
$q_ret = $pdo->query($q);
if($q_ret->rowCount() == 0)
{
header("Location: msg=Username+does+not+exist.&msgType=warning");
}
if($q_ret->fetchColumn() == $password)
{
unset($_COOKIE["username"]);
setcookie("username", null, time()-3600);
setcookie("username", $username);
unset($_COOKIE["password"]);
setcookie("password", null, time()-3600);
setcookie("password", $mysql_password);
header("Location: index.php");
}
else
{
header("Location: LogSign.php?msg=Username+and+password+do+not+match&msgType=warning");
}
}
catch (Exception $ex)
{
echo $ex->getMessage();
}