daily pastebin goal
6%
SHARE
TWEET

Untitled

a guest Jul 21st, 2017 244 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. ob_start();
  3. $host="localhost"; // Host name
  4. $username="sj"; // Mysql username
  5. $password="this r my password"; // Mysql password
  6. $db_name="sj_xbl"; // Database name
  7. $tbl_name="admins"; // 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 $sjadmin and $sjadminpass
  14. $sjadmin=$_POST['sjadmin'];
  15. $sjadminpass=$_POST['sjadminpass'];
  16.  
  17. // To protect MySQL injection (more detail about MySQL injection)
  18. $sjadmin = mysql_real_escape_string($sjadmin);
  19. $sjadminpass = mysql_real_escape_string($sjadminpass);
  20.  
  21. $sql="SELECT * FROM $tbl_name WHERE username='$sjadmin' and password='$sjadminpass'";
  22. $result=mysql_query($sql);
  23.  
  24. // Mysql_num_row is counting table row
  25. $count=mysql_num_rows($result);
  26. // If result matched $sjadmin and $sjadminpass, table row must be 1 row
  27.  
  28. if($count==1){
  29. // Register $sjadmin, $sjadminpass and redirect to file "login_success.php"
  30. session_start():
  31. $_SESSION['uid'] = $uid;
  32. $_SESSION['sjpass'] = $sjpass;
  33. header("location:login_success.php");
  34. }
  35. else {
  36. echo "Wrong Username or Password";
  37. }
  38.  
  39. ob_end_flush();
  40. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top