/
register.php
85 lines (72 loc) · 3.33 KB
/
register.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
<?php require_once ('connection.php'); ?>
<html lang="en">
<head>
<title> Registration </title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/registerStyle.css">
</head>
<body>
<div class="hero">
<form action="register.php" method="post">
<div class="container">
<div class="row justify-content-center">
<div class="col-sm-3">
<h2>Registration</h2>
<p>Please fill out the form below to register.</p>
<hr class="mb-3">
<label for="first_name"><b>First Name</b></label>
<input class="form-control" id="first_name" placeholder="Enter first name" type="text" name="first_name" required>
<label for="last_name"><b>Last Name</b></label>
<input class="form-control" id="last_name" placeholder="Enter last name" type="text" name="last_name" required>
<label for="email"><b>Email Address</b></label>
<input class="form-control" id="email" placeholder="Enter email" type="email" name="email" required>
<label for="username"><b>Username</b></label>
<input class="form-control" id="username" placeholder="Enter username" type="text" name="username" required>
<label for="password"><b>Password</b></label>
<input class="form-control" id="password" placeholder="Enter password" type="password" name="password" required>
<hr class="mb-3">
<input class="btn btn-primary" type="submit" id="register" name="create" value="Sign Up">
</div>
</div>
</div>
</form>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<script type="text/javascript">
$(function(){
$('#register').click(function(event){
var valid = this.form.checkValidity();
if(valid){
var first_name = $('#first_name').val();
var last_name = $('#last_name').val();
var email = $('#email').val();
var username = $('#username').val();
var password = $('#password').val();
event.preventDefault();
$.ajax({
type:'POST',
url: 'registerProcess.php',
data: {first_name: first_name, last_name: last_name, email: email, username: username, password: password},
success: function(data){
Swal.fire({
icon: 'success',
title: 'Success!',
text: 'Your account has been created.',
footer: '<a href="signin.php">Sign in</a>'
})
},
error: function(data){
Swal.fire({
icon: 'error',
title: 'Error',
text: 'There were errors while saving the data.'
})
}
});
}
});
});
</script>
</body>
</html>