Jump to content

Warning: Cannot modify header information


PHPiSean

Recommended Posts

I get an error stating that I cannot modify header information when I try to add a title to my login page.

Here's

<?php
session_start();

require_once("includes/dbconn.php");

include("includes/htmlheader.php");

mysql_select_db(center);

$user = $_POST['username'];
$pass = $_POST['password'];

$sql = "select username, password from users";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);

$isuser = $row['username'];
$ispass = $row['password'];

if(isset($_POST['submit'])){
if(($user==$isuser)&&($pass==$ispass)) {
$_SESSION['username'] = $user;
header("Location: home.php");
    }else{
    echo "Invalid Username or Password";
    }
}

   
?>

 

The htmlheader.php has the title string. Help is appreciated  :)

The error message, that you didn't post, tells you where the output is occurring at that is preventing the header() from working.

 

I'll guess it was a line in the htmlheader.php file? You cannot output any characters to the browser before you use a header() statement and if you are going to redirect the browser, there's no point in outputting anything, even if it did work.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.