Advertisement
Guest User

Untitled

a guest
Oct 28th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require_once '../connect/db.php';
  4.  
  5. if ($loggedin) {
  6. header("Location: index.php");
  7. exit;
  8. }
  9.  
  10. if (isset($_POST['sign_up'])) {
  11. $username = strip_tags($_POST['username']);
  12. $email = strip_tags($_POST['email']);
  13. $description = mysqli_real_escape_string(strip_tags(stripslashes($conn, $_POST['desc'])));
  14. $password = strip_tags($_POST['password']);
  15. $conPassword = $_POST['conPass'];
  16.  
  17. $passHash = password_hash($password, PASSWORD_BCRYPT);
  18.  
  19. if ($password !== $conPassword) {
  20. $msg = "Your passwords do not match!";
  21. }
  22.  
  23. $usercheck = $con->query("SELECT username FROM users WHERE username='$username'");
  24. if ($usercheck->num_rows > 0) {
  25. $msg = "Username is taken.";
  26. }
  27. $emailcheck = $con->query("SELECT email FROM users WHERE email='$email'");
  28. if ($emailcheck->num_rows > 0) {
  29. $msg = "Email is taken.";
  30. }
  31.  
  32. if(strlen($username) < 3 || strlen($username) > 32) {
  33. $msg = "<b>Warning:</b> Username must be 3-32 characters long.";
  34. }
  35.  
  36. if(strlen($password) < 6 || strlen($password) > 60) {
  37. $msg = "<b>Warning:</b> Password must be 6-60 characters long.";
  38. }
  39.  
  40. if(empty($msg)) {
  41. $query = "INSERT INTO users(username,email,password,description) VALUES('$username','$email','$passHash','$description')";
  42. if ($con->query($query)) {
  43. $msg = "<b>Success:</b> You have signed up please Signin!";
  44. }else{
  45. $msg = "<b>Error:</b> Something went wrong, Please try again!";
  46. }
  47. }
  48. }
  49. ?>
  50. <html>
  51. <head>
  52. <title>Signup | Veneria</title>
  53. <meta charset="UTF-8">
  54. <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
  55. <link rel="stylesheet" type="text/css" href="../style.css">
  56. <link rel="icon" href="/images/logos/favicon.png">
  57. </head>
  58. <body>
  59. <center><img src="../images/logo.png" class="veneria"></center>
  60.  
  61. <div id="navigation">
  62. <div id="header">
  63. <?php
  64. include '../navbar.php';
  65. include '../removebanner.php';
  66. ?>
  67. </div>
  68. </div>
  69.  
  70. <div id="container">
  71. <div id="header">
  72. <center><h1>Signup!</h1></center>
  73. <?php
  74. if (isset($msg)) {
  75. echo $msg;
  76. }
  77. ?>
  78. </div>
  79. <div id="content">
  80. <form method="POST" action="">
  81. <input type="text" style="width: 25%" placeholder="Username" name="username">
  82. <input type="text" style="width: 25%;" placeholder="Email" name="email">
  83. <input type="text" style="width: 25%;" Placeholder="Description" name="desc">
  84. <input type="password" style="width: 25%;" placeholder="Password" name="password">
  85. <input type="password" style="width: 25%;" Placeholder="Confirm Password" name="conPass">
  86. <input type="submit" class="btn green" value="Sign Up" name="sign_up">
  87. </form>
  88. </div>
  89. </div>
  90.  
  91. </body>
  92. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement