forked from vinayakmp007/Code-fortress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loging.php
76 lines (44 loc) · 1.13 KB
/
loging.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
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once ("include/mysq.php"); //conatins connection information
require_once ("include/func.php");
session_set_cookie_params(3600*3,"/");
session_start();
if(!isset($_SESSION['teamid'])||!isset($_SESSION['password'])){
if(isset($_POST['submit'])){
$tname =$_POST['teamname'] ;
$password=$_POST['password'];
$tname=test_input($tname);
$password=test_input($password); //can be avoided
$sql="SELECT id,pass,lang from team where tname='".$tname."' and pass='".$password."'";
$retval =mysqli_query($conn, $sql);
if(! $retval )
{
die('NO');
}
else{
if(mysqli_num_rows($retval)==1){
while($row = mysqli_fetch_assoc($retval)) {
$_SESSION ['teamname'] = $tname;
$_SESSION ['status'] = 'OK';
$_SESSION ['password'] = $row['pass'];
$_SESSION ['teamid'] = $row ['id'];
$_SESSION ['lang'] = $row ['lang'];
echo 'YES';
die();
}
}
else
{
die('NO');
}
}
}
else echo 'INV';
}
else {
//print_r($_SESSION);
echo 'AL'; //alreadt logged in
}
?>