hi i have been making a registration and login system i have encountered a problem when running the script on my web server. im getting this error:
Warning: Cannot modify header information - headers already sent by (output started at /home/commoncr/public_html/registeration/login.php:9) in /home/commoncr/public_html/registeration/login.php on line 25
i’m not sure what is happening it will not re direct me to the index.php.
bellow is the code im using:
[php]
<?php
require('db.php');
// If form submitted, insert values into the database.
if (isset($_POST['username'])){
$username = $_POST['username'];
$password = $_POST['password'];
$username = stripslashes($username);
$username = mysql_real_escape_string($username);
$password = stripslashes($password);
$password = mysql_real_escape_string($password);
//Checking is user existing in the database or not
$query = "SELECT * FROM `users` WHERE username='$username' and password='".md5($password)."'";
$result = mysql_query($query) or die(mysql_error());
$rows = mysql_num_rows($result);
if($rows==1){
$_SESSION['username'] = $username;
header("Location:index.php"); // Redirect user to index.php
}else{
echo "
Username/password is incorrect.
Click here to
Login
";
}
}else{
?>
[/php]