-
Notifications
You must be signed in to change notification settings - Fork 1
/
loginVerify.php
47 lines (36 loc) · 1.4 KB
/
loginVerify.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
//Starts session
session_start();
require_once('Config.php');
//Open conenction to out database useing the config file
$link = f_sqlConnect (DB_USER, DB_PASSWORD, DB_NAME);
//Clean out POST to prevent attacks
$_POST = f_clean($_POST);
//Retreave the information from POST
$name = $_POST['postname'];
$pass = $_POST['postpass'];
$match = 0; //0 means there is no match, 1 means there is a match
//look for username and password combination in database table
$sql = "SELECT * FROM `first` WHERE `username` = '$name' AND `password` = '$pass'";
$results = mysql_query($sql);
if(!$results) {
die('Invalid query: ' . mysql_error());
}
//if there is something that is returned (there is a user with the username already)
if($result = mysql_fetch_array($results)) {
//set match to 1 (found a valid user)
$match = 1;
//store username that was matched in session (session variable = database column name)
$_SESSION["user_name"] = $result['username'];
$_SESSION["pass_word"] = $result['password'];
$_SESSION["pin"] = $result['pin'];
$_SESSION["phone_number"] = $result['phonenumber'];
$_SESSION["address"] = $result['address'];
$_SESSION["bio"] = $result['bio'];
$_SESSION["extra_1"] = $result['extra1'];
$_SESSION["activation"] = $result['activation'];
$_SESSION["permissions"] = $result['permissions'];
$_SESSION["creation_time"] = $result['creationtime'];
}
echo $match;
?>