/
signup.php
executable file
·99 lines (87 loc) · 2.57 KB
/
signup.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
include 'inc/db_connect.php';
if(isset($_POST['userName'])){
$name = $_POST['name'];
$email = $_POST['email'];
$username = $_POST['userName'];
$password = $_POST['password'];
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
try{
DB::insert('users', array(
// 'uid' => '',
'name' => $name,
'email' => $email,
'username' => $username,
'password' => $hashed_password,
'status' => 1
));
}catch(MeekroDBException $e){
header('Location: /signup.php?error=yes');
exit;
}
$_SESSION['username'] =$username;
$_SESSION['uid'] = DB::insertID();
header('Location: /?callback=registration');
// print $_POST['email'];
// print $_POST['password'];
// print $hashed_password;
// exit;
//USER SUBMITTED SOMETHING.
//NOW WHAT?
//Check to see if this user is in the DB!!
$result = DB::query("SELECT * FROM users
WHERE username = '" . $_POST['userName']."'
AND password = '" . $hashed_password . "'");
// print '<pre>';
// print_r($result);
// exit;
if(mysql_num_rows($result) == 1){
//We have a match!!
$_SESSION['username'] = $_POST['userName'];
header('Location: /index.php');
}else{
//we do not have a match. Goodbye.
header('Location: http://local-phpland.com/signup.php?result=failure');
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>YikYak Login</title>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<?php
if($_GET['result'] == 'failure'){
print "<h1>Your login information does not match any record in our system. Please retry or contact Freddy.";
}
?>
<div class="container">
<div class="row">
<h1 id="signin" class="col-xs-8 col-xs-offset-2" id="login-header">Registration</h1>
</div>
<form method="post" action="signup.php">
<div class="row">
<input class="form-control" type="text" name="name" placeholder="Full Name...">
</div>
<div class="row">
<input class="form-control" type="email" name="email" placeholder="Email Address...">
</div>
<div class="row">
<input class="form-control" type="text" name="userName" placeholder="Username...">
</div>
<div class="row">
<input class="form-control" type="password" name="password" placeholder="Password...">
</div>
<div class="row">
<input class="col-xs-3 col-xs-offset-3 btn btn-success" type="submit" value="Register">
<input class="col-xs-3 btn btn-danger" type="button" value="Cancel">
</div>
</form>
</div>
</body>
</html>