Jump to content

Header


raptor30506090

Recommended Posts

Can some one help please i always get this wrong dont now why keep saying header already been sent any help please and how to fix it

 

 

 

<?php 
session_start();
$conn = mysql_connect("");
$db = mysql_select_db("", $conn);
if(isset($_POST['submit'])){
$user = mysql_escape_string($_POST['user']);
$pass = mysql_escape_string($_POST['pass']);
}
if(empty($user) && empty($pass)){
	exit;
	}else{
		} ?>
            <?php 
		$sql = mysql_query("SELECT * FROM useradmin WHERE dbusername= '".$user."' AND dbuserpass= '".$pass."'")or die(mysql_error());
		$row = mysql_fetch_assoc($sql);
		$count = count($sql);
	    $u = $row['dbusername'];
	    $p = $row['dbuserpass'];
		if($u == $user && $p == $pass){
			$_SESSION['access'] = "$u";
			header("location: index.php");
			    }else {
			    echo "Sorry there as been a problem!";
			    exit;
				}
		?>

Link to comment
Share on other sites

you are outputting empty chars.

 

if(empty($user) && empty($pass)){
	exit;
	}else{
		} ?>
            <?php 
		$sql 

 

 

should be

 

if(empty($user) && empty($pass)){
	exit;
	}else{
		} 
		$sql 

 

why open and close the tags??

 

any characters before a header statement will throw this error.

Link to comment
Share on other sites

if what you have posted is  your entire header then removing the <?php ?> tags will fix it.

If you have other content in between the tags then it will not work.

 

You cannot output any character whatsoever before sending a header().

 

so if you do this:

 

echo ' ';
header (foo);

 

it will fail.

 

if you do this:

 

 <?php header(foo); ?>

 

it will fail. (notice the space before <)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.