-
Notifications
You must be signed in to change notification settings - Fork 0
/
loggedin.php
47 lines (32 loc) · 1.05 KB
/
loggedin.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
<?php
# BikeShed version 0.0.0.2
# File version 0.0.0.2
# BikeShed
# https://github.com/Trekkie101/bikeshed
# loggedin.php
# Carry out main authentication and login the user
include 'config.php';
mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
if(!empty($_POST['Username'])) {
$username = $_POST['Username'];
$password = $_POST['Password'];
$username = htmlentities($username);
$username = mysql_real_escape_string($username);
$password = htmlentities($password);
$password = mysql_real_escape_string($password);
$result = mysql_query("SELECT id FROM bs_users WHERE username='$username' AND password='$password'") or die(mysql_error());
$row = mysql_fetch_array($result);
$id = (int)$row['id'];
if($id > 0) {
session_start();
$_SESSION['userId'] = $id;
$_SESSION['username'] = $username;
header("Location: index.php");
} else{header("Location: login.php?incorrect=9");
}
} else{
header("Location: login.php?incorrect=9");
}
mysql_close();
?>