-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstdinc.php
More file actions
executable file
·90 lines (76 loc) · 2.54 KB
/
Copy pathstdinc.php
File metadata and controls
executable file
·90 lines (76 loc) · 2.54 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
include 'sql.php';
session_start();
function plogin ()
{
print "<a href='login.php'>LOGIN</a>";
}
function plogout()
{
print "<a href='login.php'>LOGOUT</a>";
}
function psumary($uid)
{
print "<a href='sumary.php?id=" . $uid . "'> click here to go to sharable user sumary </a><br>";
}
function errormsg($msg){
print "ERROR!!!! " . $msg . "<br>";
}
function login($username,$password){
global $userinfo;
$result=mysql_query("select * from users where username='" . $username . "' and password = '" . $password . "'");
if($row1=mysql_fetch_array($result)){
$cookie=rand();
$id=$row1['id'];
$rr2=mysql_query("select max(sessionid) from sessions");
$rr2=mysql_fetch_array($rr2);
$sesid=$rr2[0] + 1;
//print "session id " . $sesid;
$_SESSION['sesid']=$sesid;
$_SESSION['cookie']=$cookie;
$lgnq="insert into sessions values ( " . $sesid . ", " . $id . ", " . $cookie . ")";
mysql_query($lgnq);
$result=mysql_query("select * from users where id = " . $id );
if($userinfo=mysql_fetch_array($result)){
print "<br> WELCOME " . $userinfo['firstname'] . " " . $userinfo['lastname'] . "<br><br>";
}
}else
{
errormsg("invalid login");
plogin();
exit;
}
}
function sumarize($id){
//print $id;
global $userinfo;
$result=mysql_query("select * from users where id = " . $id );
if($userinfo=mysql_fetch_array($result)){
//print $userinfo['firstname'];
print "<table>";
print "<tr><td>firstname: </td><td>" . $userinfo['firstname'] . "</td></tr>";
print "<tr><td>lastname: </td><td>" . $userinfo['lastname'] . "</td></tr>";
print "<tr><td>age: </td><td>" . $userinfo['age'] . "</td></tr>";
$qq="select count(id) from users where age = " . $userinfo['age'];
//print "<br>" . $qq ;
$result=mysql_query($qq);
$rr1=mysql_fetch_array($result);
print "<tr><td>how many users this age: </td><td>" . $rr1[0] . "</td></tr>";
print "</table>";
}else{
errormsg("invalid userid");
exit;
}
}
if ( $_SESSION['sesid'] )
{
$query = "select userid from sessions where cookie = " . $_SESSION['cookie'] . " and sessionid = " . $_SESSION['sesid'] ;
$result=mysql_query($query);
$row1=mysql_fetch_array($result);
$userid=$row1[0];
$result=mysql_query("select * from users where id = " . $userid );
if($userinfo=mysql_fetch_array($result)){
//print "<br> WELCOME " . $userinfo['firstname'] . " " . $userinfo['lastname'] . "<br><br>";
}
}
?>