I receive message when validation is O.K. and Username and password not valid.
Error is the following:
Warning: Cannot modify header information - headers already sent by (output started at index.php) in login...
This is when ELSE is performed: header("Location: home.php");
Do you have suggestions? It recognised my name even I did not put any
data into login FORM.![]()
I have the following script:
PHP Code:<?
/* Connect to MySQL-Server */
...
/* Open $db */
...
$user = $_POST['username'];
$pswr = $_POST['password'];
$query ="SELECT * FROM users WHERE
username = '$user'
AND " ."
password = '$pswr'";
$result = mysql_query($query) or die("ERROR: " . mysql_error());
if(mysql_num_rows($result) > 0) # we found a match, so set $_SESSION flag:
{
$_SESSION['logged'] = TRUE;
if(isset($_SESSION['caller']))
# if we got here from another page, go there
{
header("Location: " . $_SESSION['caller']);$loginvalid=1;
}
else
# otherwise go to main page
{
header("Location: home.php");
}
}
else
# invalid login, so create error message
{
if ($validation=='true'&& (mysql_num_rows($result)==0))
{$errorinput="This <b>Username or Password</b> is not valid!<br />"; }
else {$errorinput==""; }
}
?>


Reply With Quote
Bookmarks