-
Notifications
You must be signed in to change notification settings - Fork 0
/
registration.php
129 lines (120 loc) · 3.79 KB
/
registration.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
session_start();
?><!DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf-8>
<link rel="stylesheet" type="text/css" href="sketchy.css">
<title>Sketchy | Registration</title>
</head>
<body>
<div id="page-wrap">
<div class="row1">
<header>
<div class="col-1">
<div id="headleft">
<h1>Sketchy</h1>
</div>
<span id="sub">SVG for You and Me</span>
</div>
</header>
</div>
<div class="row2">
<nav>
<div class="col-1-3">
<a href='#'>about</a>
</div>
<div class="col-1-3">
<a href='#'>resources</a>
</div>
<div class="col-1-3">
<a href='#'>terms and conditions</a>
</div>
</nav>
</div>
<?php
if(isset($_POST['submit']) && $_POST['submit'] == "register")
{
include("inc_sketchy_connect.php");
if ($DBConnect === FALSE)
{
die("<p>Connection error: " . mysqli_error() . "</p>\n");
}
else
{
if ($DBSelect === FALSE)
{
die("<p>Could not select the \"$DBName\" " . "database: " .
mysqli_error($DBConnect) . "</p>\n");
}
//making email address lowercase in all cases:
$tempmail = mysqli_real_escape_string($DBConnect, $_POST["email"]);
$email = strtolower($tempmail);
$user = mysqli_real_escape_string($DBConnect, $_POST["user"]);
$sword = sha1(mysqli_real_escape_string($DBConnect,$_POST["sword"]));
if (empty($email))
{
echo "<p class='error'>Please try again to register below. All fields are
required.</p>";
}
else if (empty($user) || empty($sword))
{
echo "<p class='error'>Please try again to register simply. Enter a username
and password.</p>";
}
//must see if this person is already registered:
else if (!empty($email))
{
$query = "SELECT * FROM sketcher WHERE email='$email'";
$result = mysqli_query($DBConnect, $query);
$count = mysqli_num_rows($result);
if ($count==1)
{
die( "<p class='error'>It seems you are already registered with
Sketchy. Please visit the <a href='index.php'>Login</a> Page.</p>");
}
else
{
$query1 =
"INSERT INTO sketcher
(username, email, sword)
VALUES ('$user', '$email', '$sword')";
$result1 = mysqli_query($DBConnect, $query1);
$query2 =
"SELECT * FROM sketcher;";
$result2 = mysqli_query($DBConnect, $query2);
$sketcherid = mysqli_num_rows($result2);
$_SESSION['sketcherid'] = $sketcherid;
$_SESSION['user'] = $user;
header('Location: home.php');
}//ends error checking registration else statement
}//ends the final else if
mysqli_close($DBConnect);
}//ends successful DBConnect else statement
}//ends POST submit
?>
<section>
<form action="registration.php" method="post">
<table class="login">
<tr>
<td>Username:</td>
<td><input type = "text" name = "user" maxlength = "10" size = "10" />
(between 4 and 10 characters)</td>
</tr><tr>
<tr>
<td>Password:</td>
<td><input type = "password" name = "sword" maxlength = "10" size = "10" />
(between 4 and 10 characters)</td>
</tr>
<td>Email:</td>
<td><input type = "text" name = "email" maxlength = "256" size = "50" />
</td>
</tr>
</table>
<br />
<input class="button" type="submit" name = "submit" value = "register" />
</form>
</section>
</div><!--end page-wrap-->
</body>
</html>