-
Notifications
You must be signed in to change notification settings - Fork 0
/
form.php
113 lines (93 loc) · 3.83 KB
/
form.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
<?php
require_once("config.php");
try{
$connString = "mysql:host=" . DBHOST . ";dbname=" .DBNAME;
$user = DBUSER;
$pass = DBPASS;
$pdo =null;
}catch(PDOException $e){
print "ERROR!: " . $e->getMessage() . "<br/>";
die();
}
session_start();
$_SESSION['message'] = '';
$mysql;
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
if($_POST['password'] == $_POST['confirmpassword']){
$username = $mysql->real_escape_string($_POST['username']);
$email = $mysql->real_escape_string($_POST['email']);
$password = md5($_POST['password']);
$sql = "INSERT INTO users (username, email, password)"
."VALUES ('$username', '$email', '$password')";
if ($mysql->query($sql) == true){
$_SESSION['message'] = 'Succesful!';
header("location: home.php");
}
}
else {
$_SESSION['message'] = "Passwords do not match";
}
}
?>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>REGISTER</title>
<link href= "dist/css/bootstrap.min.css" rel="stylesheet">
<link href= "assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<link href= "carousel/carousel.css" rel="stylesheet">
<link rel="stylesheet" href="form.css" type="text/css">
<div class="navbar-wrapper" id="nav" class="sticky" class="topnav">
<div class="container">
<nav class="navbar navbar-inverse navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">F&F</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#food">Food</a></li>
</ul>
<div class="search-container">
<form action="/action_page.php">
<input type="text" placeholder="Search.." name="search">
<button type="submit"><i class="fa fa-search"></i></button>
</form>
</div>
</div>
</div>
</nav>
</div>
</div>
</br>
<div class="body-content">
<div class="module">
<h1>Create an account</h1>
<form class="form" action="form.php" method="post" enctype="multipart/form-data" autocomplete="off">
<div class="alert alert-error"><?= $_SESSION['message'] ?></div>
<input type="text" placeholder="User Name" name="username" required /></br>
<input type="email" placeholder="Email" name="email" required /></br>
<input type="password" placeholder="Password" name="password" autocomplete="new-password" required /></br>
<input type="password" placeholder="Confirm Password" name="confirmpassword" autocomplete="new-password" required /></br>
<input type="submit" value="Register" name="register" class="btn btn-block btn-primary" />
</form>
</div>
<button onclick="goBack()">Go Back</button>
<script>
function goBack() {
window.history.back();
}
</script>
</div>
<footer>
<p class="pull-right"><a href="#">Back to top</a></p>
<p>© 2018 FnF Company, Inc. · <a href="#">Privacy</a> · <a href="#">Terms</a></p>
</footer>