Jump to content


Photo

login not working?


  • Please log in to reply
10 replies to this topic

#1 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 30 June 2006 - 08:55 PM

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!

<?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>';
}
}
?>


#2 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 01 July 2006 - 12:57 AM

anybody?

#3 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 01 July 2006 - 01:12 AM

o.O This's my first time seeing this
$uname = @$_POST['uname'];
$pass = @$_POST['pwd'];

Try removing the @

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#4 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 01 July 2006 - 01:14 AM

still not working, it worked with those before though.

#5 kals

kals
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 01 July 2006 - 01:39 AM

where do you get $LOGIN_METHOD from?
make sure it is defined and value is correct


#6 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 01 July 2006 - 01:41 AM

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.

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 01 July 2006 - 04:35 AM

session_start(); is not in the correct order put it to the top of all  your pages ok.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 kals

kals
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 01 July 2006 - 04:59 AM


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?


#9 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 01 July 2006 - 05:04 AM

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.........
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#10 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 02 July 2006 - 03:19 AM

well it could use sessions or cookies....

#11 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 02 July 2006 - 03:24 AM

sorry to moan but i think a good login totural will help try the one on here.

good luck.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users