Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2017
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. $_SESSION['message'] = '';
  5.  
  6. $mysqli = new mysqli('localhost', 'uname', 'pass', 'accounts');
  7.  
  8. if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  9.  
  10. // making sure passswords match (equal to each other)
  11. if ($_POST['password'] == $_POST['confirmpassword']) {
  12.  
  13. $username = $mysqli->real_escape_string($_POST['username']);
  14. $email = $mysqli->real_escape_string($_POST['email']);
  15. $password = md5($_POST['password']); // hashing password, security reason(s)
  16.  
  17. $sql = "INSERT INTO users (username, email, password)
  18. VALUES ('$username', '$email', '$password')";
  19.  
  20. //if the query is successful redirect to account page
  21. if ($mysqli->query($sql) === true) {
  22. $_SESSION['message'] = "Account Registration Successful, welcome $username";
  23. header("Location: welcome.php");
  24. }
  25. else {
  26. $_SESSION['message'] = "Account Registration Unsuccessful";
  27. }
  28. }
  29. }
  30. ?>
  31.  
  32. <!doctype html>
  33. <html>
  34. <head>
  35. <meta charset="utf-8">
  36. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  37. <title>Abyssal: Account Maintainance</title>
  38. <link rel="stylesheet" href="css/form.css" type="text/css">
  39. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  40. <script src="js/jquery-1.11.3.min.js"></script>
  41. </head>
  42. <body>
  43. <div class="wrapper-content">
  44. <div class="wrapper-scene">
  45. <div class="container">
  46. <h3><strong>Undying Account Creation</strong></h3>
  47. <hr>
  48. <p></p>
  49. <div class="topspacing10"></div>
  50. <form class="form" action="form.php" method="post" enctype="multipart/form-data" autocomplete="off">
  51. <div class="alert alert-error"><?= $_SESSION['message']?></div>
  52. <input type="text" placeholder="Username" name="username" required>
  53. <input type="email" placeholder="Email" name="email" required>
  54. <input type="password" placeholder="Password" name="password" autocomplete="new-password" required>
  55. <input type="password" placeholder="Confirm Password" name="confirmpassword" autocomplete="new-password" required>
  56. <input type="submit" value="Register" name="register" class="btn btn-block btn-primary">
  57. </form>
  58. </div>
  59. </div>
  60. </body>
  61. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement