Help on my login

Posted on Wednesday 12th November 2008 at 08:42 PM
peza
peza's Avatar
I'm not getting any type of errors in this code but i have a problem in which it will only check if the feilds are empty anything after that say eg. User not found, will be white even when i try to login on my registered acount it also go's white, any help would be cool thanks.

PHP Code
  1. <?php
  2. session_start();
  3. include "inc/db_connect.php";
  4. echo "<title>OnlineGamerBase</title>";
  5. echo "<link rel='stylesheet' href='stylesheet.css' type='text/css'/>";
  6. echo "<center>";
  7.  
  8. if($logged[id]) {
  9. print "$logged[username], you are being redirected...";
  10. echo "<meta http-equiv='Refresh' content='2; URL=index2.php'/>";
  11. }else
  12. if(isset($_GET['login'])) {
  13. if((!$_POST[username]) || (!$_POST[password])) {
  14. print "ERROR: A feild was left blank please go <a href='index.php'>back</a> and try again.";
  15. }
  16. }else
  17. if(isset($_GET['login'])) {
  18. $username= htmlspecialchars(addslashes($_POST[username]));
  19. $password = sha1(md5(md5(sha1(md5(sha1(sha1(md5($_POST[password]))))))));
  20. $uinfo = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error());
  21. $checkuser = mysql_num_rows($uinfo);
  22. if($checkuser == '0')
  23. {
  24. print "Username not found"; ;
  25. }else{
  26. $udata = mysql_fetch_array($uinfo);
  27. if($udata[active] == 0) {
  28. print "Error: This account has not been verified, go <a href='index.php'>back</a>.";
  29. }
  30. else
  31. if($udata[password] == $password) {
  32. $query = mysql_query("SELECT * FROM `users` WHERE `username` = '$username'") or die(mysql_error());
  33. $user = mysql_fetch_array($query);
  34. $_SESSION['id'] = "$user[id]";
  35. $_SESSION['password'] = "$user[password]";
  36.  
  37. print "You are now logged in, Please wait. . .";
  38. echo "<meta http-equiv='Refresh' content='2; URL=index2.php'/>";
  39. }
  40.  
  41. else{
  42. print "ERROR: Incorrect username or password! Go <a href='index.php'>back</a>.";
  43. }
  44. }
  45. }else{
  46. echo "
  47. <br>
  48. <br>
  49. <u>Login</u>
  50.  
  51.  
  52. <form action='index.php?login' method='post'>
  53. Username:
  54. <input name='username' type='text' maxlength='15' />
  55.  
  56.  
  57. Password:
  58. <input name='password' type='password' maxlength='15' />
  59.  
  60.  
  61. <input name='submit' type='submit' value='Submit' />
  62. </form>
  63. <br>";
  64. }
  65. echo "<center>";
  66. ?>
Posted on Wednesday 12th November 2008 at 10:05 PM
jambomb
jambomb's Avatar
i dont really know what you mean ??
Posted on Wednesday 12th November 2008 at 10:10 PM
peza
peza's Avatar
its alright i just took the feild check out for now it seemed to be the problem
Login or register to respond to this forum topic.