Guest User

Untitled

a guest
Dec 15th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. if ($_SERVER['REQUEST_METHOD'] == 'POST'){
  2. //two passwords are the same
  3. if($_POST['password'] == $_POST['confirmedpassword']) {
  4.  
  5. $username = $mysqli->real_escape_string($_POST['username']);
  6. $password = md5($_POST['password']);
  7.  
  8. $_SESSION['username'] = $username;
  9. $_SESSION['password'] = $password;
  10.  
  11. $sql = "INSERT INTO members(username, password)"
  12. . "VALUES ('$username','$password')";
  13.  
  14. //if querey is successful redirect to login.php
  15. if($mysqli->query($sql) === true)
  16. $_SESSION['message'] = 'Success';
  17. header("location: login.php");
  18.  
  19. }
  20. else{
  21. $_SESSION['message'] = "User couldnt be added";
  22.  
  23. }
  24. }
  25. else{
  26. $_SESSION['message'] = "Passwords dont match";
  27. }
Add Comment
Please, Sign In to add comment