Advertisement
keysle

Thy Login code no work

Jun 21st, 2012
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. Could someone explain to me why my login page is not working?
  2. I created this account. You can try it at http://k.k8r.us/login.php
  3. username: k
  4. password: star
  5.  
  6. or you can create your own here: http://k.k8r.us/signup.php
  7.  
  8. Here is my login page. It submits to itself, and if there is a successful login it 301 redirects to your "dashy dashboard"
  9. [php]
  10. <?php
  11. require('inc/common.php');
  12. require('inc/validationKit.php');
  13. require('inc/dbConnect.php');
  14. //require('inc/recaptchalib.php');
  15.  
  16. $username = $_GET['username'];
  17.  
  18. if ( isset($_POST['submitted']) ){
  19. $username = $_POST['username'];
  20. $password = $_POST['password'];
  21.  
  22. $hashword = md5($password);
  23.  
  24. //initialize error tracking
  25. $errors = 0;
  26. $errors_username = array();
  27. $errors_overall = array();
  28.  
  29. //check username && combo
  30. if (strlen($username)>0){
  31. $result = mysql_query("SELECT * FROM users WHERE ( name='$username' && hashword='$hashword') LIMIT 1");
  32. $nameExist = mysql_num_rows($result);//die("$username ... $nameExist ... $password");
  33. if (!$nameExist){
  34. array_push($errors_overall,"Username or Password is incorrect.");
  35. }
  36. }
  37. else {
  38. array_push($errors_username,"you must insert a Username or Email to login");
  39. }
  40. //----- END check username && combo
  41.  
  42. //collect all errors
  43. $errors = 0;
  44. $errors += count($errors_username);
  45. $errors += count($errors_overall);
  46.  
  47. //create account
  48. if (0 == $errors){
  49. $data = mysql_fetch_row($result);
  50. $_SESSION['userID'] = $data['ID'];
  51. $_SESSION['username'] = $data['username'];
  52. //print_r($data);
  53. //die();
  54. //jump to dashboard
  55. header( 'Location: dashboard.php' );die();
  56. }
  57. }
  58. ?>
  59. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  60. <html>
  61. <head>
  62. <title>Login</title>
  63. <?php include("inc/meta.php");?>
  64. </head>
  65. <body>
  66. <?php include("inc/header.php");?>
  67. <?php $navLight="logging";include("inc/nav.php");?>
  68.  
  69. <?php if (isset($errors) && $errors) echo $errors;?>
  70. <form action="" method="POST">
  71. <span class="errors">
  72. <?php
  73. if (isset($_GET['m']) && $_GET['m'] == '1') {
  74. echo "<span class=\"error\">You must be logged in to view that page. God you're stupid</span>";
  75. }
  76. ?>
  77. <?= html_listArray($errors_overall) ?></span>
  78. <label>
  79. Username or Email: <input id="username" type="text" name="username" value="<?= $username ?>"/>
  80. <span class="errors"><?= html_listArray($errors_username) ?></span>
  81. </label>
  82. <label>
  83. Password: <input id="password" type="password" name="password"/>
  84. </label>
  85. <input name="submitted" type="hidden" value="1">
  86. <input type="submit" value="Submit"/>
  87. </form>
  88. <?php include("inc/footer.php");?>
  89. </body>
  90. </html>
  91. [/php]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement