PHP Login problem

Hi all,
I have a login script, it works with 1st sql row ‘username’ & ‘password’, but it can’t login with 2nd or 3rd row ‘username’ & ‘password’. what is the problem ?
Thanks

index.php script is : [php]<?php
include(“config.php”);
session_start();
$error = “”;
if($_SERVER[“REQUEST_METHOD”] == “POST”)
{
// username and password sent from Form
$myusername=addslashes($_POST[‘username’]);
$mypassword= md5($_POST[‘password’]);
$myusername= htmlspecialchars($_POST[‘username’]);

$sql=“SELECT uid FROM user WHERE username=’$myusername’ and password=’$mypassword’”;

$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$active=$row[‘active’];
$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1)
{
session_register(“myusername”);
$_SESSION[‘login_user’]=$myusername;

header(“location: dashboard.php”);
}
else
{
$error=“Your Login Name or Password is invalid”;
}
}
?>

Admin Login

UserName :
Password :

<?php print $error ; ?>
[/php]

I’m pretty much new to php…can’t guarantee that it will work…

Make two files

[ul][li]index.php[/li]
[li]login.php[/li][/ul]

Put the php code i.e all the code above

<link href="style.css" rel="stylesheet" type="text/css" />

in login.php

Now put the rest of the code in index.php and edit the following line

[code]

[/code As [code] [/code]

I hope this works for you :smiley:

Could you clarify what you mean by “2nd or 3rd row”? I don’t see any rows in anything that you posted.

Sponsor our Newsletter | Privacy Policy | Terms of Service