Results 1 to 6 of 6
Related
-
mypsace modify friends help? Forum: Myspace Forum
Replies: 0 -
Premature end of script headers error Forum: CGI Perl Forum
Replies: 1 -
Question about Headers (I think) Forum: HTML Forum
Replies: 5
-
05-24-2009, 06:55 AM #1
Warning: Cannot modify header information - headers already sent by (output started a
hi,
can anybody help me i this regards.
problem is as follows
i have a form .
here i am getting a value through a file.
based on the value i decide the header.but before that i pass a meta data also.
<html>
<meta http-equiv="refresh" content="2;url=http://localhost/cba.php" />
<?php
$handle=fopen('c:/aaa.txt','r');
$a=fgets($handle);
fclose($handle);
if($a!=0)
header( 'refresh: 5; url=http://localhost/abc.php' );
else
header( 'refresh: 5; url=http://localhost/cba.php' );
?>
</html>
so here once i do this a warning will come up saying
"Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\abc.php:7) in C:\Program Files\Apache Group\Apache2\htdocs\abc.php on line 462
"
so can anyone give me solution for this.pls
-
05-29-2009, 12:46 PM #2
Re: Warning: Cannot modify header information - headers already sent by (output start
Sorry about the delayed response. I have been gone for a little while, but I am back now.
When using the header() function in PHP, there can be nothing output to the screen before the function is called. Any HTML is considered output to the screen. What you need to do is move your PHP code to before the HTML as follows:
PHP Code:<?php
$handle=fopen('c:/aaa.txt','r');
$a=fgets($handle);
fclose($handle);
if($a!=0)
header( 'refresh: 5; url=http://localhost/abc.php' );
else
header( 'refresh: 5; url=http://localhost/cba.php' );
?>
<html>
<meta http-equiv="refresh" content="2;url=http://localhost/cba.php" />
</html>Last edited by jthayne; 05-29-2009 at 12:53 PM.
-
08-26-2009, 12:19 AM #3
Re: Warning: Cannot modify header information - headers already sent by (output start
Viola? Why not Bass Fiddle?
-
11-02-2009, 03:44 AM #4
Re: Warning: Cannot modify header information - headers already sent by (output start
hi,
i m getting the same "Cannot modify header information - headers already sent in .. " error. There's no white space b4 or after php tags. Here is my code-
<? ob_start(); ?>
<?php
session_start();
if(isset($_POST['login']))
{
if(!$fh = fopen('pwd.dat','w')) {
do_error_exit('Error opening data file. <br />Please contact the system administrator. <br />Sorry for the inconvenience.');
}
$username1[0]= 'kaly';
$username1[1]= crypt('mypassword','rl');
$user_pass_string= implode('=',$username1);
fwrite($fh,"$user_pass_string\n");
flock($fh);
flush($fh);
fclose($fh);
$username = $_POST['username'];
$password = $_POST['pswd'];
$tempwd = crypt($password,'rl');
$fh = fopen('pwd.dat','r');
for($line = fgets($fh); !feof($fh) ; $line = fgets($fh))
{
$line = trim($line);
$userData = explode("=",$line);
if ($userData[0] == $username)
$pass = $userData[1];
}
fclose($fh);
if (crypt($password, $pass) == $pass){
$_SESSION['phplogin'] = true;
header('Location: index.php');
exit;
} else {
?>
<script type="text/javascript">
<!--
alert('Wrong Password, Please Try Again')
//-->
</script>
<?php
}
}
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> PHP Login </title>
</head>
<body>
<center>
Username:<br>
Password:<br>
<form method="post" action="">
<input type="username" name="username">
<input type="password" name="pswd">
<input type="submit" name="login" value="Login">
</form>
</center>
</body>
</html>
<? ob_flush(); ?>
-
11-02-2009, 01:23 PM #5
Re: Warning: Cannot modify header information - headers already sent by (output start
I would say Short Tags are not enabled on your host. You can change it in your php.ini file but it is easiest to fix the code.
Change:
PHP Code:<? ob_start(); ?>
PHP Code:<?php ob_start(); ?>
-
11-04-2009, 10:11 AM #6
Re: Warning: Cannot modify header information - headers already sent by (output start
Actually what needs to happen, is you need to move
PHP Code:<? ob_start(); ?>
My recommendation is to move it just before this line:
HTML Code:<script type="text/javascript">
Cloudjiffy- PaaS for Developers
10-05-2020, 12:30 AM in Web Hosting Forum