Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. $db = mysqli_connect("localhost", "root", "", "authentication");
  5.  
  6. if(isset($_POST['register_btn']))
  7. {
  8. $username = mysql_real_escape_string($_POST['username']);
  9. $password = mysql_real_escape_string($_POST['password']);
  10. $password2 = mysql_real_escape_string($_POST['password2']);
  11.  
  12. if ($password == $password2 )
  13. {
  14. $password = md5($password);
  15. $sql = "INSERT INTO users(username, password) VALUES('$username', '$password')";
  16. mysqli_query($db, $sql);
  17. $_SESSION['message'] = "You are now logged in";
  18. $_SESSION['username'] = $username;
  19. header("location: home.php");
  20. }else
  21. {
  22. $_SESSION['message'] = "The two passwords do not match";
  23. }
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement