Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. <?php
  2.  
  3. include_once 'config.php';
  4.  
  5. function loginform()
  6. {
  7.  
  8. // Display a login form
  9. echo'
  10. <form name="loginform" method="post" action="login.php">
  11. Username: <input name="username" type="text" id="username" /><br />
  12. Password: <input name="password" type="text" id="password" /><br />
  13. <input type="submit" name="Submit" value="Login" />
  14. </form>
  15. ';
  16. }
  17.  
  18.  
  19. function checklogin()
  20. {
  21.  
  22. global $dbName, $dbHost, $dbUser, $dbPass;
  23. print $dbHost;
  24. // Connect to the database
  25. mysql_connect($dbHost, $dbUser, $dbPass)or die("Cannot connect to MySQL");
  26. mysql_select_db($dbName)or die("Cannot select DB");
  27.  
  28. // Get the submit details
  29. $username=$_POST['username'];
  30. $password=$_POST['password'];
  31.  
  32. // Make details safe
  33. $username = mysql_real_escape_string($username);
  34. $password = mysql_real_escape_string($password);
  35.  
  36. $sql="SELECT * FROM users WHERE username='$username' and password='$password'";
  37. $result=mysql_query($sql);
  38.  
  39. $count=mysql_num_rows($result);
  40.  
  41. if($count==1){
  42. session_register("username");
  43. session_register("password");
  44. echo' hello logged in';
  45. }
  46. else {
  47. echo "Wrong Username or Password";
  48. }
  49.  
  50. }
  51.  
  52. if(!isset($password)){
  53. print 'hello';
  54. }
  55. else { checklogin();
  56. }
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement