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
https://forums.phpfreaks.com/topic/247333-header/
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
https://forums.phpfreaks.com/topic/247333-header/#findComment-1270238
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
https://forums.phpfreaks.com/topic/247333-header/#findComment-1270249
Share on other sites

This is the error it says

 

Warning: Cannot modify header information - headers already sent by (output started at /home/content/80/5047580/html/webdazsign/admin/script/loginS.php:13) in /home/content/80/5047580/html/webdazsign/admin/script/loginS.php on line 21

Link to comment
https://forums.phpfreaks.com/topic/247333-header/#findComment-1270261
Share on other sites

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.