Page 1 of 1

PHP Login Redirect Problem

Posted: Tue Nov 16, 2010 1:57 pm
by jevic
Hi

I am having a problem with my php login code Each time I log in I am being redirected back to the login. Could you please look at my code and see what I am doing wrong.

Thankyou

<?php
session_start();
mysql_connect("localhost", "c3254640","c3254640")or die("cannot connect");
mysql_select_db("c3254640")or die("cannot select DB");
$Username=$_POST['Username'];
$Password=$_POST['Password'];
$query = "SELECT * FROM User WHERE Username= '$Username' AND Password='$Password'";
$result = mysql_query ($query);
if (mysql_num_rows($result) > 1)
{
$_SESSION["authenticatedUser"] = $Username;
header("Location: logonpage.php");
}
else
{
$_SESSION["message"] = "Could not connect as $Username " ;
header("Location: login.php");
}
?>

Re: PHP Login Redirect Problem

Posted: Tue Nov 16, 2010 2:26 pm
by WorldCom
Try

Code: Select all

if (mysql_num_rows($result) >= 1)

Re: PHP Login Redirect Problem

Posted: Tue Nov 16, 2010 2:38 pm
by jevic
WorldCom wrote:Try

Code: Select all

if (mysql_num_rows($result) >= 1)
thankyou for the reply but that still doesnt fix it

Re: PHP Login Redirect Problem

Posted: Tue Nov 16, 2010 2:58 pm
by Celauran
Have you also checked the code in logonpage.php? Could it be redirecting you back to login.php?

Re: PHP Login Redirect Problem

Posted: Tue Nov 16, 2010 3:47 pm
by thinsoldier
Did you accidentally set your login form tag to GET instead of post?