daily pastebin goal
52%
SHARE
TWEET

Untitled

a guest May 31st, 2017 94 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="biasedga_logink"; // Mysql username
  5. $password="loginpassword"; // Mysql password
  6. $db_name="biasedga_login"; // Database name
  7. $tbl_name="Data"; // 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 $myusername and $mypassword
  14. $myusername=$_POST['myusername'];
  15. $mypassword=$_POST['mypassword'];
  16.  
  17. // To protect MySQL injection (more detail about MySQL injection)
  18. $myusername = stripslashes($myusername);
  19. $mypassword = stripslashes($mypassword);
  20. $myusername = mysql_real_escape_string($myusername);
  21. $mypassword = mysql_real_escape_string($mypassword);
  22.  
  23. $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
  24. $result=mysql_query($sql);
  25.  
  26. // Mysql_num_row is counting table row
  27. $count=mysql_num_rows($result);
  28. // If result matched $myusername and $mypassword, table row must be 1 row
  29.  
  30. if($count==1){
  31. // Register $myusername, $mypassword and redirect to file "login_success.php"
  32. session_register("myusername");
  33. session_register("mypassword");
  34. header("location:login_success.php");
  35. }
  36. else {
  37. echo "Wrong Username or Password";
  38. }
  39.  
  40. ob_end_flush();
  41. ?>
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