-
Notifications
You must be signed in to change notification settings - Fork 0
/
Login.php
60 lines (55 loc) · 1.81 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
if(!isset($_SESSION))
{
session_start();
}
include_once ('smarty_init.php');
include_once ('class/user/Login.php');
include_once ('class/user/ResultReturn.php');
require_once 'class/Injection.php';
function try_to_login()
{
$username = Injection::excute('username');
$password = Injection::excute('pwd');
// echo $username;
// echo $password;
include_once('class/DBtraverser.php');
include_once('class/Config.php');
include_once('class/Config_user.php');
$myDBtraveser = new DBtraverser(Config_user::table_name, ' where '.Config_user::log_name."='$username'");
$retval = $myDBtraveser->excute_without_conn();
//handle the login result
if (mysqli_num_rows($retval)==0){
echo "<script language='javascript'> alert('wrong log name!');
window.history.go(-1);
</script>";
}else
{
$complete_ary = mysqli_fetch_array($retval, MYSQLI_ASSOC);
if( $complete_ary[Config_user::password] == $password )
{
$_SESSION['CURRENT_LOGIN_USER'] = $username;
$_SESSION['CURRENT_LOGIN_ID'] = $complete_ary[Config_user::id];
mysqli_free_result($retval);
header("Location:Commodity_browse.php");
}
else
{
mysqli_free_result($retval);
echo "<script language='javascript'> alert('wrong password!');
window.history.go(-1);
</script>";
}
}
}
if (isset($_POST['login'])){
try_to_login();
}else if (isset($_POST['reg'])){
$smarty->display("Login&Register/register1.html");
}else if (isset($_POST['forget'])){
$smarty->display("forget.html");
}else{
// echo "in";
// var_dump("$smarty");
$smarty->display("Login&Register/Login.html");
}