Jump to content

Archived

This topic is now archived and is closed to further replies.

localhost

login not working?

Recommended Posts

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]<?php
ob_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]

Share this post


Link to post
Share on other sites
o.O This's my first time seeing this
[code]$uname = @$_POST['uname'];
$pass = @$_POST['pwd'];[/code]

Try removing the @

Share this post


Link to post
Share on other sites
where do you get $LOGIN_METHOD from?
make sure it is defined and value is correct

Share this post


Link to post
Share on other sites
it is from config.php which is included and traces all the way back to SESSION

so 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.

Share this post


Link to post
Share on other sites
session_start(); is not in the correct order put it to the top of all  your pages ok.

Share this post


Link to post
Share on other sites

session_start() should actually work ok where it is as it is bieng called before outputting anything to the browser

what exactly do you mean by "doesn't work at all"?
Do you get invalid password error, warnings, a blank page or something else?

Share this post


Link to post
Share on other sites
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.........

Share this post


Link to post
Share on other sites
sorry to moan but i think a good login totural will help try the one on here.

good luck.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.