Advertisement
Guest User

Untitled

a guest
Sep 16th, 2017
115
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. $host = "localhost";
  3. $username = "myuser";
  4. $password = "isgiosgdL";
  5. $db_name = "mydb123";
  6. mysql_connect($host, $username, $password) or die (mysql_error());
  7. mysql_select_db($db_name) or die (mysql_error_db());
  8. $myusername = mysql_real_escape_string($_POST['username']);
  9. $mypassword = mysql_real_escape_string($_POST['password']);
  10. $sql = "SELECT `username` FROM `members` WHERE `username`='$myusername'
  11. and `password`='$mypassword'";
  12. echo $sql;
  13. $result=mysql_query($sql) or die('Query Error: ' . mysql_error() . "<br
  14. />\n$sql");
  15. echo $sql;
  16. echo $result;
  17. $count = mysql_num_rows ($result); // moved this line to AFTER you've executed the query
  18. echo mysql_num_rows($result);
  19. if($count>0) { session_start(); $_SESSION['logged_in'] =
  20. true;
  21. header("Location: login_success.php"); exit; }
  22. else { echo "Wrong Username or Password"; }
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement