Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $_SESSION['message'] = '';
- $mysqli = new mysqli('localhost', 'uname', 'pass', 'accounts');
- if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- // making sure passswords match (equal to each other)
- if ($_POST['password'] == $_POST['confirmpassword']) {
- $username = $mysqli->real_escape_string($_POST['username']);
- $email = $mysqli->real_escape_string($_POST['email']);
- $password = md5($_POST['password']); // hashing password, security reason(s)
- $sql = "INSERT INTO users (username, email, password)
- VALUES ('$username', '$email', '$password')";
- //if the query is successful redirect to account page
- if ($mysqli->query($sql) === true) {
- $_SESSION['message'] = "Account Registration Successful, welcome $username";
- header("Location: welcome.php");
- }
- else {
- $_SESSION['message'] = "Account Registration Unsuccessful";
- }
- }
- }
- ?>
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Abyssal: Account Maintainance</title>
- <link rel="stylesheet" href="css/form.css" type="text/css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
- <script src="js/jquery-1.11.3.min.js"></script>
- </head>
- <body>
- <div class="wrapper-content">
- <div class="wrapper-scene">
- <div class="container">
- <h3><strong>Undying Account Creation</strong></h3>
- <hr>
- <p></p>
- <div class="topspacing10"></div>
- <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="Username" name="username" required>
- <input type="email" placeholder="Email" name="email" required>
- <input type="password" placeholder="Password" name="password" autocomplete="new-password" required>
- <input type="password" placeholder="Confirm Password" name="confirmpassword" autocomplete="new-password" required>
- <input type="submit" value="Register" name="register" class="btn btn-block btn-primary">
- </form>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement