[PHP] Re: : [PHP] header information problem

2004-12-23 Thread Angelo Zanetti
I would agree with Yangshiqi

 yangshiqi [EMAIL PROTECTED] 12/18/04 1:41 PM 
And if you have some special intent, you can use ob_start().

 
Best regards,
Yang Shiqi
 
 
 
--
: yangshiqi [mailto:[EMAIL PROTECTED] 
: 20041218 19:36
: 'Ahmed Abdel-Aliem'; 'php-general@lists.php.net'
: : [PHP] header information problem

I don't understand why you want to include header.html before you redirect
the users to the login_success.php?

By the way, you 'd better to add mysql_escape_string() with the username and
password to ensure the security of your code. Coz we can't believe any
users' input from web. May be the sql injection with your site.
Just be careful.

Best regards,
Yang Shiqi

--
: Ahmed Abdel-Aliem [mailto:[EMAIL PROTECTED] 
: 20041218 18:52
: php-general@lists.php.net 
: [PHP] header information problem

Dear Groups members.

i am making a user protected page, the script works excellent on my
local server, but online it gives me this error :

Warning: Cannot modify header information - headers already sent by
(output started at
/home/me2resh/public_html/apex/upload/header.html:10) in
/home/me2resh/public_html/apex/upload/upload.php on line 33

the script of the page is 

?
if (!isset($ID)){
include 'header.html';
echo No ID is Set.brYou Got To This Page By Mistake;
include 'footer.html';
}else{
session_start();  
include 'db.php'; 
include 'header.html';
$username = $_POST['username']; 
$password = $_POST['password']; 
if((!$username) || (!$password)){ 
echo Please enter ALL of the information! br /; 
include 'login_form.html'; 
include 'footer.html'; 
exit(); 
}
$sql = mysql_query(SELECT * FROM user WHERE User_Login='$username'
AND User_Password='$password');
$login_check = mysql_num_rows($sql); 
if($login_check  0){
session_register('ID'); 
$_SESSION['ID'] = $ID;  
while($row = mysql_fetch_array($sql)){ 
foreach( $row AS $key = $val ){ 
$$key = stripslashes( $val ); 
} 
session_register('User_First_Name'); 
$_SESSION['User_First_Name'] = $User_First_Name; 
session_register('User_Last_Name'); 
$_SESSION['User_Last_Name'] = $User_Last_Name;   
session_register('User_ID'); 
$_SESSION['User_ID'] = $User_ID; 
header(Location: login_success.php); 
}
}else{
include 'header.html';
echo You could not be logged in! Either the username and
password
do not match!br /
Please try again!br /; 
include 'login_form.html'; 
include 'footer.html'; 
}
} 
?


Can anyone help me with that problem please ?

-- 
Ahmed Abdel-Aliem
www.ApexScript.com 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php 



Disclaimer
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is
intended for the attention and use only of the addressee.
Should you have received this e-mail in error, please delete
and destroy it and any attachments thereto immediately.
Under no circumstances will the Cape Peninsula University of
Technology or the sender of this e-mail be liable to any party for
any direct, indirect, special or other consequential damages for any
use of this e-mail.
For the detailed e-mail disclaimer please refer to
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] header information problem

2004-12-20 Thread Richard Lynch




Ahmed Abdel-Aliem wrote:
 Dear Groups members.

 i am making a user protected page, the script works excellent on my
 local server, but online it gives me this error :

Your local server has output_buffering turned ON in php.ini

Your online server does not.

 Warning: Cannot modify header information - headers already sent by
 (output started at
 /home/me2resh/public_html/apex/upload/header.html:10) in
 /home/me2resh/public_html/apex/upload/upload.php on line 33
.
.
.
   include 'header.html';
.
.
.
 header(Location: login_success.php);

First of all, you CANNOT do header once PHP has started sending
HTML/content to the browser.

Think (or learn) about how HTTP headers and content works, and it will be
obvious why.

Secondly, header(Location: ...) is BAD PROGRAMMING!

The Location: header is part of the HTTP protocol to inform browsers when
a document has *MOVED*.

You have *not* moved your login script, nor your success page, nor any
other on-line document.

You are using (abusing) the Location: header as if it were a PHP
programming construct such as 'if/else/while/include/echo/...' which it is
not.

Don't do that.

You would be MUCH better off to just:
include 'login_success.php';
here.

You might need to re-structure a few things in your code, but it will be
much cleaner in the end.

In the short run, you can just turn on output buffering on your online
server, and it will work  --  In the long run, your code will be
difficult to maintain, impossible to debug, and have weird logic until you
re-structure it to deal with any kind of 'headers' first, then use include
to pull in the correct html/php, and never, ever, ever, use
header(Location: ) for anything except a document that has moved from
one URL to another.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] header information problem

2004-12-18 Thread Gareth Williams
In the else part, you have the possibility to echo to the screen and 
later on, then header(Location: ...);

This is the bit which isn't allowed.
If you are doing header(Location: ...);, you are not allowed to echo 
before it.

On 18 Dec 2004, at 11:52, Ahmed Abdel-Aliem wrote:
Dear Groups members.
i am making a user protected page, the script works excellent on my
local server, but online it gives me this error :
Warning: Cannot modify header information - headers already sent by
(output started at
/home/me2resh/public_html/apex/upload/header.html:10) in
/home/me2resh/public_html/apex/upload/upload.php on line 33
the script of the page is
?
if (!isset($ID)){
include 'header.html';
echo No ID is Set.brYou Got To This Page By Mistake;
include 'footer.html';
}else{
session_start();
include 'db.php';
include 'header.html';
$username = $_POST['username'];
$password = $_POST['password'];
if((!$username) || (!$password)){
echo Please enter ALL of the information! br /;
include 'login_form.html';
include 'footer.html';
exit();
}
$sql = mysql_query(SELECT * FROM user WHERE User_Login='$username'
AND User_Password='$password');
$login_check = mysql_num_rows($sql);
if($login_check  0){
session_register('ID');
$_SESSION['ID'] = $ID;
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key = $val ){
$$key = stripslashes( $val );
}
session_register('User_First_Name');
$_SESSION['User_First_Name'] = $User_First_Name;
session_register('User_Last_Name');
$_SESSION['User_Last_Name'] = $User_Last_Name;
session_register('User_ID');
$_SESSION['User_ID'] = $User_ID;
header(Location: login_success.php);
}
}else{
include 'header.html';
echo You could not be logged in! Either the username and 
password
do not match!br /
Please try again!br /;
include 'login_form.html';
include 'footer.html';
}
}
?
Can anyone help me with that problem please ?
--
Ahmed Abdel-Aliem
www.ApexScript.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Header information ...

2003-01-10 Thread Daniel Kushner
Hi Anders,

You can't send a header to the browser once output has been sent. The
header() function should be before any other output on your script. Further
more, because the script isn't terminated after the header() function, and
you usually do not want to continue running it, an exit() should directly
follow.
e.g.:
Header(Location: main.php);
exit();


Regards,
Daniel Kushner
_
Need hosting? http://thehostingcompany.us



 -Original Message-
 From: Anders Mellstrom [mailto:[EMAIL PROTECTED]]
 Sent: Friday, January 10, 2003 11:18 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Header information ...


 Hello. I can't get this code to work. The error message I get is
 that the header could be added, cause it has allready been sent.
 What shalll I do to get it to work?

 //Anders

 html
 head
 title/title
 meta http-equiv=Content-Type content=text/html; charset=iso-8859-1

 script language=JavaScript
 if ((navigator.appName == Netscape) 
 (parseInt(navigator.appVersion)  5))
 {
 window.alert(Upgrade version of NS.);
 }
 else
 {
 document.write(?php $i = 1 ?);
 }
 /script

 link rel='stylesheet' href='stil.css' type='text/css'
 /head
 body

 br

 ?php
   if ($i == 1)
   {

   Header(location:main.php);
   }
   else
   {
   print(Byt webblauml;sare!);
   }
 ?
 /body
 /html



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Header information ...

2003-01-10 Thread Marek Kilimajer
Should look like this:

Anders Mellström wrote:


Hello. I can't get this code to work. The error message I get is that the header could be added, cause it has allready been sent. What shalll I do to get it to work?

//Anders

?php
	if ($i == 1)
	{
		
		Header(location:main.php);


   exit;


	}
	else
	{
		//print(Byt webblauml;sare!);  -- displayed later
	}
?html
head
title/title
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1

script language=JavaScript
if ((navigator.appName == Netscape)  (parseInt(navigator.appVersion)  5))
{
window.alert(Upgrade version of NS.);
}
else
{
document.write(?php $i = 1 ?);
}
/script

link rel='stylesheet' href='stil.css' type='text/css'
/head
body

br
Byt webblauml;sare!

/body
/html



 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Header Information for Formatting?

2002-05-02 Thread Jason Wong

On Thursday 02 May 2002 21:05, Jay Blanchard wrote:
 G' morning!

 Can someone tell me where to find the various options for the Header
 function as it relates to M$ Excel? Yesterday, thanks to this list, we
 found a way to open a worksheet in the browser and display data retrieved
 from a database. The worksheet opens with no gridlines and displaying zero
 values, I would like to see gridlines and no zero values. Are there options
 that can be placed in the header function. I have looked at MSDN and did a
 Google search that did not reveal much of anything.

 Here is the header info being used...

 header(Content-Type:  application/x-excel);
 header(Content-Disposition: inline; filename=\excel.xls\);
 header(Expires: 0);
 header(Cache-Control: must-revalidate, post-check=0, pre-check=0);

M$ Excel is not a browser (not yet anyway, and hopefully it doesn't evolve 
into one), thus http headers are not pertinent to how Excel displays it's 
data. Try fiddling with Excel's display options.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
marriage, n.:
Convertible bonds.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php