localhost Posted June 30, 2006 Share Posted June 30, 2006 well see, i made a login that used to work and doesnt anymore, displays no error, just reshows the box :( no idea what went wrong![code]<?phpob_start();$uname = @$_POST['uname'];$pass = @$_POST['pwd'];print "<centeR>";require('includes/connect.php');require('includes/config.php');require('global/global_header.php');//encrypt password before checking against SQL database$encpass = md5($pass);//connect to database and check passwaord username combination and get permissions$query = "SELECT * from users where username = '$uname' and password = '$encpass'";$result = mysql_query($query) or die('Query failed: ' . mysql_error() . '<hr>There has been an error in the application, please contact the administrator<hr><b>Error: E001</b>');$uid="";while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){$permissions =$row['auth'];$uid = $row['uid'];}if ($LOGIN_METHOD == "COOKIE"){if ($uid!=""){setcookie("DotOmega1", $uname);setcookie("DotOmega2", $permissions);setcookie("DotOmega3", $uid);print "<head><title>.Omega alpha testing</title><link href=\"omega_themes/default/default.css\" rel=\"stylesheet\" type=\"text/css\" /></head>";echo "<br>You have logged in as: ".$uname; print "<br><br><br><a href=\"index.php\">If you are not redirected automaticaly please follow this link</a>";echo '<script>document.location = "index.php";</script>';} else {print "<head><title>$PAGE_TITLE - Login</title><link href=\"omega_themes/default/default.css\" rel=\"stylesheet\" type=\"text/css\" /></head>";print "<font face=tahoma size=2 color=336ab3><b><br><br>";echo 'You did not log in sucessfully please try again.<form method=post action=login.php>Username:<input type="text" name="uname" id="uname"><br>Password:<input type="password" name="pwd" id="pwd"><br><input type="submit" value="Log In"></form><a href=user_registration.php>Register</a>';print "</font></b>";}}if ($LOGIN_METHOD == "SESSION"){session_start();$_SESSION['user_name'] = $uname;$_SESSION['auth'] = $permissions;$_SESSION['uid'] = $uid;if ((isset($_SESSION['user_name']))&&(isset($_SESSION['auth']))&&(isset($_SESSION['uid']))){print "<head><title>.Omega alpha testing</title><link href=\"omega_themes/default/default.css\" rel=\"stylesheet\" type=\"text/css\" /></head>";echo "<br>You have sucessfully logged in as: ".$_SESSION['user_name'];print "<br><br><br><a href=\"index.php\">If you are not redirected automaticaly please follow this link</a>";echo '<script>document.location = "index.php";</script>';} else {print "<head><title>$PAGE_TITLE</title><link href=\"omega_themes/default/default.css\" rel=\"stylesheet\" type=\"text/css\" /></head>";echo 'You did not log in sucessfully please try again. <form method=post action=login.php>Username:<input type="text" name="uname" id="uname"><br> Password:<input type="password" name="pwd" id="pwd"><br><input type="submit" value="Log In"> </form>';}}?>[/code] Quote Link to comment Share on other sites More sharing options...
localhost Posted July 1, 2006 Author Share Posted July 1, 2006 anybody? Quote Link to comment Share on other sites More sharing options...
hackerkts Posted July 1, 2006 Share Posted July 1, 2006 o.O This's my first time seeing this[code]$uname = @$_POST['uname'];$pass = @$_POST['pwd'];[/code]Try removing the @ Quote Link to comment Share on other sites More sharing options...
localhost Posted July 1, 2006 Author Share Posted July 1, 2006 still not working, it worked with those before though. Quote Link to comment Share on other sites More sharing options...
kals Posted July 1, 2006 Share Posted July 1, 2006 where do you get $LOGIN_METHOD from? make sure it is defined and value is correct Quote Link to comment Share on other sites More sharing options...
localhost Posted July 1, 2006 Author Share Posted July 1, 2006 it is from config.php which is included and traces all the way back to SESSIONso I have no idea whats going on, it used to work perfectly, then on the main page say welcome, username. and when you posted on the forums it put your username in as the poster. now it doesnt work at all. Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 1, 2006 Share Posted July 1, 2006 session_start(); is not in the correct order put it to the top of all your pages ok. Quote Link to comment Share on other sites More sharing options...
kals Posted July 1, 2006 Share Posted July 1, 2006 session_start() should actually work ok where it is as it is bieng called before outputting anything to the browserwhat exactly do you mean by "doesn't work at all"?Do you get invalid password error, warnings, a blank page or something else? Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 1, 2006 Share Posted July 1, 2006 Not to be a brat or anythink but session_start ();should always be at the top of any script.Even if you are not outputting any data its always good code pratice.Tell us more about your problam cheers......... Quote Link to comment Share on other sites More sharing options...
localhost Posted July 2, 2006 Author Share Posted July 2, 2006 well it could use sessions or cookies.... Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 2, 2006 Share Posted July 2, 2006 sorry to moan but i think a good login totural will help try the one on here.good luck. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.