Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. $host="localhost"; // Host name
  4. $username="sj"; // Mysql username
  5. $password="BLEEPS"; // Mysql password
  6. $db_name="sj_xbl"; // Database name
  7. $tbl_name="members"; // Table name
  8.  
  9. // Connect to server and select databse.
  10. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  11. mysql_select_db("$db_name")or die("cannot select DB");
  12.  
  13. // Define $tag and $sjpass
  14. $tag=$_POST['tag'];
  15. $sjpass=$_POST['sjpass'];
  16.  
  17. // To protect MySQL injection (more detail about MySQL injection)
  18. $tag = stripslashes($tag);
  19. $sjpass = stripslashes($sjpass);
  20. $tag = mysql_real_escape_string($tag);
  21. $sjpass = mysql_real_escape_string($sjpass);
  22.  
  23. $sql="SELECT * FROM $tbl_name WHERE tag='$tag' and password='$sjpass'";
  24. $result=mysql_query($sql);
  25.  
  26. // Mysql_num_row is counting table row
  27. $count=mysql_num_rows($result);
  28. // If result matched $tag and $sjpass, table row must be 1 row
  29.  
  30. if($count==1){
  31. // Register $tag, $sjpass and redirect to file "login_success.php"
  32. $_SESSION['tag'] = $tag;
  33. session_register("sjpass");
  34. header("location:login_success.php?tag=$tag");
  35. }
  36. else {
  37. header("Location: login.php?m=Invalid+username+or+password");
  38. }
  39.  
  40. ob_end_flush();
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement