Advertisement
Guest User

Untitled

a guest
Jan 11th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. $host="localhost"; // Host name
  4. $username="root"; // Mysql username
  5. $password="pass"; // Mysql password
  6. $db_name="stuffs"; // Database name
  7. $tbl_name="users"; // Table name
  8.  
  9. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  10. mysql_select_db("$db_name")or die("cannot select DB");
  11.  
  12. $myusername=$_POST['username'];
  13. $mypassword=$_POST['password'];
  14.  
  15. $myusername = stripslashes($myusername);
  16. $mypassword = stripslashes($mypassword);
  17. $myusername = mysql_real_escape_string($myusername);
  18. $mypassword = mysql_real_escape_string($mypassword);
  19. $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
  20. $result=mysql_query($sql);
  21.  
  22. $count=mysql_num_rows($result);
  23.  
  24. if($count==1){
  25. echo "success";
  26. // Register $myusername, $mypassword and redirect to file "login_success.php"
  27. //session_register("myusername");
  28. //session_register("mypassword");
  29. //header("location:login_success.php");
  30. }
  31. else {
  32. echo "Wrong username or password.";
  33. }
  34. ob_end_flush();
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement