This repository was archived by the owner on Nov 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSignup.php
More file actions
83 lines (64 loc) · 2.22 KB
/
Copy pathSignup.php
File metadata and controls
83 lines (64 loc) · 2.22 KB
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
<?php session_start() ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sign up as Guest</title>
</head>
<body>
<a href="login.php">Return to login screen</a>
<form method="post">
<p>
<label for="User">Username:</label><br>
<input type="text" id="User" name="User"/><br>
<label for="Pass">Password:</label><br>
<input type="text" id="Pass" name="Pass"/><br>
<label for="Email">Email:</label><br>
<input type="text" id="Email" name="Email"><br>
<label for="Name">Name:</label><br>
<input type="text" id="Name" name="Name"/><br>
<label for="Cell">Cellphone #:</label><br>
<input type="text" id="Cell" name="Cell"/><br>
<label for="Address">Address:</label><br>
<input type="text" id="Address" name="Address"><br>
</p>
<input type="submit" value="Signup" name="Signup"/>
</form>
</body>
</html>
<?php
/**
* Created by PhpStorm.
* User: Jared
* Date: 2018-11-01
* Time: 2:23 PM
*/
if (isset($_SESSION['Username'])) {
header('Location:restricted.php');
}
$host = "localhost";
$user = "root";
$password = "";
$dbName = "proj_db";
$connect = mysqli_connect($host, $user, $password, $dbName) or die("Connection Failed");
//Allows a guest to sign up and add the account to the DB
if (!empty($_POST['User'])) {
$User = $_POST["User"];
$User = mysqli_real_escape_string($connect, $User);
$Pass = $_POST["Pass"];
$Pass = mysqli_real_escape_string($connect, $Pass);
$Cell = $_POST["Cell"];
$Cell = mysqli_real_escape_string($connect, $Cell);
$Email = $_POST["Email"];
$Email = mysqli_real_escape_string($connect, $Email);
$Name = $_POST["Name"];
$Name = mysqli_real_escape_string($connect, $Name);
$Address = $_POST["Address"];
$Address = mysqli_real_escape_string($connect, $Address);
//$query = "insert into guest values('$User','$Pass','$Name','$Cell','$Email','$Address')";
$query = "INSERT INTO user_info values (null ,'$Name','$Email','$User','$Pass','$Cell','$Address','0')";
$result = mysqli_query($connect, $query);
if ($result) {
header('Location:login.php?signup=1');
} else echo "Account Creation Failed" . mysqli_error($connect);
}