-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauth.php
56 lines (48 loc) · 1.48 KB
/
auth.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
<?php
session_start();
include ("variables.php");
$id = $_POST['id'];
$password = $_POST['password'];
/*try {
$conn = new PDO('mysql:host=localhost;dbname=book4me', 'rachit', 'mario');
echo 'Connected to database';
}
catch(PDOException $e)
{
echo $e->getMessage();
}*/
$conn = new PDO("mysql:host = $dbhost;dbname=$dbname",'root');
$sql = "select * from `login` where `id` = '$id'";
if($q = $conn->query($sql)){
$r = $q->fetch();
if(!isset($r['id'])){
$_SESSION['newid']=$id;
$_SESSION['newpassword']=$password;
/*echo ("Username not in database. <a href='signup.php'>Create</a> a new account");*/
echo ('<form name="input" action="signup.php" method="GET">
Facebook id: <input type="text" name="facebook"><br>
Name: <input type="text" name="name"><br>
<input type="submit" value="Submit"></form>');
}
else if($r['id']==$id && $r['password']==$password && $r['activated']==1) {
$_SESSION['id']=$r['id'];
$_SESSION['password']=$r['password'];
$_SESSION['name']=$r['name'];
$_SESSION['facebook']=$r['facebook'];
echo $_SESSION['id'];
$_SESSION['priority']=$r['priority'];
header('Location: main.php');
//echo '<a href="main.php"> main </a>';
}
else if($r['id']==$id && $r['password']==$password && $r['activated']!=1) {
echo "please activate your account";
echo '<a href="login.php">CLick</a> here';
}
else echo "keep out";
}
else
{
echo "failed to connect";
echo "click <a href='main.php'> here </a> to go back";
}
?>