[f9c482b] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | if($_SERVER["REQUEST_METHOD"] === "POST")
|
---|
| 4 | {
|
---|
| 5 |
|
---|
| 6 | if(empty($_POST['email']))
|
---|
| 7 | {
|
---|
| 8 | header("Location: /Sign Up.php?error=INVALID_EMAIL");
|
---|
| 9 | exit();
|
---|
| 10 | }
|
---|
| 11 |
|
---|
| 12 | if(empty($_POST['username']))
|
---|
| 13 | {
|
---|
| 14 | header("Location: /Sign Up.php?error=INVALID_USERNAME&email=".$_POST['email']);
|
---|
| 15 | exit();
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | if(empty($_POST["password"]))
|
---|
| 19 | {
|
---|
| 20 | header("Location: /Sign Up.php?error=INVALID_PASSWORD&email=".$_POST['email']."&username=".$_POST['username']);
|
---|
| 21 | exit();
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | require 'connect.php';
|
---|
| 25 |
|
---|
| 26 | $input_name = $_POST['username'];
|
---|
| 27 | $input_email = $_POST['email'];
|
---|
| 28 | $input_password = $_POST['password'];
|
---|
| 29 |
|
---|
| 30 | $res = $conn->query('SELECT * FROM Users WHERE Username="'.$input_name.'";');
|
---|
| 31 |
|
---|
| 32 | if($res->num_rows >= 1)
|
---|
| 33 | {
|
---|
| 34 | header("Location: /Sign Up.php?error=USERNAME_TAKEN&email=".$_POST['email']."&username=".$_POST['username']);
|
---|
| 35 | exit();
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | $res = $conn->query('SELECT * FROM Users WHERE Email="'.$input_email.'"');
|
---|
| 39 |
|
---|
| 40 | if($res->num_rows >= 1)
|
---|
| 41 | {
|
---|
| 42 | header("Location: /Sign Up.php?error=EMAIL_TAKEN&email=".$_POST['email']."&username=".$_POST['username']);
|
---|
| 43 | exit();
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | try
|
---|
| 47 | {
|
---|
| 48 | $conn->query('INSERT INTO Users (Username, Email, Password) VALUES ("'.$input_name.'", "'.$input_email.'", "'.$input_password.'");');
|
---|
| 49 | } catch(Exception $e)
|
---|
| 50 | {
|
---|
| 51 | echo $e->getMessage();
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
| 54 | else
|
---|
| 55 | {
|
---|
| 56 | header("Location: /register.php");
|
---|
| 57 | exit();
|
---|
| 58 | }
|
---|
| 59 | ?>
|
---|
| 60 |
|
---|
| 61 | <!DOCTYPE html>
|
---|
| 62 | <html lang="en">
|
---|
| 63 | <head>
|
---|
| 64 | <meta charset="UTF-8">
|
---|
| 65 | <meta http-equiv="X-UA-Compatible" content="IE=edge">
|
---|
| 66 | <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
---|
| 67 | <link rel="stylesheet" href="./CSS/validateSignUp.css">
|
---|
| 68 | <title>Successful Registration</title>
|
---|
| 69 | </head>
|
---|
| 70 | <body>
|
---|
| 71 | <div class="register-content">
|
---|
| 72 | <img src="image/green_tick_icon.png" alt="Green Tick Icon" width=250 height=250>
|
---|
| 73 | <h1>You have successfully registered</h1>
|
---|
| 74 | <p>You may now log in</p>
|
---|
| 75 | <a href="Log In.php">Log In</a>
|
---|
| 76 | </div>
|
---|
| 77 | </body>
|
---|
| 78 | </html> |
---|