Guest User

Untitled

a guest
Nov 7th, 2018
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. if(isset($_POST['username']) && isset($_POST['password'])){
  6.  
  7. $dbc_form = mysqli_connect("localhost","root","","register");
  8.  
  9. $username = $_POST['username'];
  10. $password = $_POST['password'];
  11.  
  12. $query = "SELECT * FROM register WHERE username='$username' AND password='$password'";
  13.  
  14. $result = mysqli_query($dbc_form,$query);
  15.  
  16. if(mysqli_num_rows($result) == 1){
  17.  
  18. $row = mysqli_fetch_array($result);
  19. $_SESSION['name'] = $row['name'];
  20. $_SESSION['login'] = "LOGGED IN";
  21. header("Location: index.php");
  22. }
  23. else{
  24.  
  25. $_SESSION['error_msg'] = "Wrong uppgifter!";
  26. $_SESSION['login'] = "LOGGED OUT";
  27. header("Location: index.php");
  28. }
  29. }
  30. else{
  31. $_SESSION['error_msg'] = "Wrong information";
  32. header("Location: index.php");
  33. }
  34. ?>
Add Comment
Please, Sign In to add comment