-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewVisitorReg.php
143 lines (104 loc) · 4.03 KB
/
newVisitorReg.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
include("config.php");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST") {
$sql = "INSERT INTO User (Username, Email, Password, UserType) VALUES ('" . $_POST['username'] . "', '" . $_POST['email'] . "', '" . md5($_POST['password']) . "', 'VISITOR' )";
$result = mysqli_query($db,$sql);
if($result == true) {
$_SESSION['login_user'] = $_POST['username'];
$_SESSION['user_type'] = 'VISITOR';
header("Location: visitorDashboard.php");
} else {
echo "<script type='text/javascript'>alert('There was an error creating the account');</script>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<?php include("head.php"); ?>
<script>
function validateForm() {
var x = document.forms["visitReg"]["password"].value;
var y = document.forms["visitReg"]["confirmpassword"].value;
if (x != y) {
alert("Passwords must match");
return false;
}
if (x.length < 8) {
alert("Passwords must have at least 8 characters");
return false;
}
var email = document.forms["visitReg"]["email"].value;
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if(!re.test(String(email).toLowerCase())) {
alert("Email must be a valid email address");
return false;
}
var username = document.forms["visitReg"]["username"].value;
if(username = "") {
alert("Username cannot be empty");
return false;
}
}
</script>
<body>
<?php include("loginNavbar.php"); ?>
<!--==========================
Main Section
============================-->
<section id="hero">
<div class="hero-container">
<!-- <h1>Welcome</h1> -->
<h2>Atlanta Gardens, Farms, and Orchards</h2>
<div class="card">
<div class="card-body">
<form name="visitReg" onsubmit="return validateForm()" class="form-horizontal" action='newVisitorReg.php' method='post'>
<fieldset>
<!-- Form Name -->
<legend>New Visitor Registration</legend>
<br>
<!-- Text input-->
<div class="form-group">
<div class="col-md-12">
<input id="email" name="email" type="text" placeholder="Email" class="form-control input-md" required="">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<div class="col-md-12">
<input id="username" name="username" type="text" placeholder="Username" class="form-control input-md" required="">
</div>
</div>
<!-- Password input-->
<div class="form-group">
<div class="col-md-12">
<input id="password" name="password" type="password" placeholder="Password" class="form-control input-md" required="">
</div>
</div>
<!-- Password input-->
<div class="form-group">
<div class="col-md-12">
<input id="confirmpassword" name="confirmpassword" type="password" placeholder="Confirm Password" class="form-control input-md" required="">
</div>
</div>
<!-- Submit Button -->
<div class="col-md-12">
<input class="btn-get-started" type="submit" value="Create Account">
</div>
<br>
<div class="col-md-12">
<div class="row">
<!-- Registration Links -->
<div class="col-md-3">
<a class="btn btn-success style-bkg" href="index.php">Back</a> <br>
</div>
</div> <!-- End Row -->
</div> <!-- End Column -->
</fieldset> <!-- End Fieldset -->
</form> <!-- End Form -->
</div> <!-- End Card Body -->
</div> <!-- End Card -->
</div>
</section>
</body>
</html>