-
Notifications
You must be signed in to change notification settings - Fork 1
/
logintest.php
63 lines (51 loc) · 1.52 KB
/
logintest.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
58
59
60
61
62
63
<?php
ob_start();
//session_save_path("tmp");
//connect to our database
require('database.php'); //location of databse info class etc.
//we should be connected
if ( !isset($_GET['eid']) and !isset($_GET['pasword']) ){
echo 'Please login Again.<br/>';
//header('login.php');
}
else
{
$result; // this holds the results of msql queries
$query; // this is the text you want to send to msql
$user =$_GET['eid'] ; //not sure whats going but you need a space before characters
$password =$_GET['password'] ;
//$query = 'select eid,name from employee where username=\'' . $user . '\' and password=\'' . $password .'\' ';
$query = "select eid,seniority,name from employee where eid=$user and password='$password'";
$result = mysql_query($query);
echo $query . '<br/>';
if ( mysql_num_rows($result) > 0 )
echo 'User exists <br />';
else
echo 'User not found <br/>';
if ( mysql_num_rows($result) ) { //mysql_num_rows($result) > 0 ) {
//session_register("user");
//session_register("password");
session_start();
$_SESSION = array(); //free up session first
$_SESSION['user'] = $user;
//$_SESSION['password'] = $password;
$_SESSION['eid'] = $user;
$_SESSION['logged'] =1 ;
$row = mysql_fetch_array($result);
echo $row['seniority'];
if( $row['seniority'] == 'Manager')
$_SESSION['manager'] = 1;
else
$_SESSION['manager'] = 0;
$_SESSION['ename'] = $row['name'];
header("location:index.php");
}
else{
echo "fail";
$_SESSION = array(); //kills session
//session_destroy();
header("location:logout.php");
}
}
ob_end_flush();
?>