Advertisement
Guest User

server

a guest
Mar 15th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $username="";
  4. $email="";
  5. $errors=array();
  6. $db=mysqli_connect('localhost','root','','registration');
  7. if(isset($_POST['register'])){
  8. $username=$_POST['username'];
  9. $email=$_POST['email'];
  10. $password_1=$_POST['password_1'];
  11. $password_2=$_POST['password_2'];
  12. if(empty($username)){
  13. array_push($errors,"Username is required");
  14. }
  15. if(empty($email)){
  16. array_push($errors,"Email is required");
  17. }
  18. if(empty($password_1)){
  19. array_push($errors,"Password is required");
  20. }
  21. if($password_1!=$password_2){
  22. array_push($errors,"Passwords do not match");
  23. }
  24. if(count($errors)==0){
  25. $password=md5($password_1);
  26. //$sql="INSERT INTO users(username,email,password) VALUES('$username','$email','$password')";
  27. //mysqli_query($db,$sql);
  28. $__SESSION['username']=$username;
  29. $__SESSION['success']="You are logged in";
  30. //session_regenerate_id(true);
  31. header('location: index.php');
  32. }
  33. }
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement