Guest User

Untitled

a guest
Dec 19th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. <?php
  2. if(isset($_SESSION['id'])) {
  3. header("Location: user.php");
  4. }
  5. if(isset($_POST['register'])) {
  6. $db = mysqli_connect("localhost", "nunomarquina", "Amaral47",
  7. "proyecto_ets2mp");
  8.  
  9. $username = strip_tags($_POST['username']);
  10. $password = strip_tags($_POST['password']);
  11. $password_confirm = strip_tags($_POST['password_confirm']);
  12. $mail = strip_tags($_POST['email']);
  13.  
  14. $username = stripslashes($username);
  15. $password = stripslashes($password);
  16. $password_confirm = stripslashes($password_confirm);
  17. $mail = stripslashes($mail);
  18.  
  19. $username = mysqli_real_escape_string($db, $username);
  20. $password = mysqli_real_escape_string($db, $password);
  21. $password_confirm = mysqli_real_escape_string($db, $password_confirm);
  22. $mail = mysqli_real_escape_string($db, $mail);
  23.  
  24. $password = md5($password);
  25. $password_confirm = md5($password_confirm);
  26.  
  27. $sql_store = "INSERT INTO users (username, password, email) VALUES ('$username', '$password', '$mail')";
  28. $sql_fetch_username = "SELECT username FROM users WHERE username = '$username'";
  29. $sql_fetch_mail = "SELECT email FROM users WHERE email = '$mail'";
  30.  
  31. $query_username = mysqli_query($db, $sql_fetch_username);
  32. $query_mail = mysqli_query($db, $sql_fetch_mail);
  33.  
  34. }
  35. ?>
  36.  
  37. <!doctype html>
  38. <html>
  39. <head>
  40. <link rel="stylesheet" href="assets/css/main.css"/>
  41. <title>Register form</title>
  42. </head>
  43. <body>
  44. <div id="login">
  45. <h1>Register</h1>
  46. <form action="register.php" method="post" enctype="multipart/form-data">
  47. <input placeholder="Username" name="username" type="text">
  48. <input placeholder="Password" name="password" type="password">
  49. <input placeholder="Confirm Password" name="password_confirm" type="password">
  50. <input placeholder="E-Mail Adress" name="email" type="text">
  51. <input name="register" type="submit" value="Register">
  52. </form>
  53. <h2>Tienes una cuenta?</h2>
  54. <h2><a href="login.php">Inicia Sesion</a></h2>
  55. </div>
  56. </body>
  57. </html>
Add Comment
Please, Sign In to add comment