Re: [PHP] Header Keep-Alive

2013-05-27 Thread Sebastian Krebs
2013/5/27 Al n...@ridersite.org

 I'm trying to increase the connection timeout; but can't get it to work.
 Note: Keep-Alive gets repeated.

 I'm using:
 header(Connection: Keep-Alive);
 header(Keep-Alive: timeout=9, max=100);


Set the second optional argument to true
See http://de.php.net/manual/en/function.header.php




 I get:
 (Status-Line)   HTTP/1.1 200 OK
 DateMon, 27 May 2013 20:19:54 GMT
 Server  Apache
 Connection  Keep-Alive, Keep-Alive
 Keep-Alive  timeout=5, max=100
 Expires Thu, 19 Nov 1981 08:52:00 GMT
 Cache-Control   no-store, no-cache, must-revalidate, post-check=0,
 pre-check=0
 Pragma  no-cache
 Content-Encodinggzip
 VaryAccept-Encoding,User-Agent
 Set-Cookie  Coach::VermontCamp2013_**setupMode=**
 58d7e534bec4ec57634c78caa59d8d**b2; expires=Sat, 23-Nov-2013 20:19:55
 GMT; path=/Coach/; domain=.ridersite.org
 Transfer-Encoding   chunked
 Content-Typetext/html; charset=utf-8

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




-- 
github.com/KingCrunch


RE: [PHP] header function odd behavior

2011-06-28 Thread Ford, Mike
 -Original Message-
 From: H Rao [mailto:hydsd...@gmail.com]
 Sent: 28 June 2011 04:40
 
 I am trying to understand odd(different) behavior of the header
 function
 under two different environments.
 
 Here is the code which I am trying to execute from two different
 servers
 
 ?
 header (Set-Cookie: c1=value1;path=/; domain=.domain.com);
 header (Set-Cookie: c2=value2;path=/; domain=.domain.com);
 ?
 
 When executed from server1(OS X), both cookies are set in browser,
 but when
 executed from server2(Linux), only the second cookie is set.
 
 server1 and server2 are running different OS and php version as
 below. I
 know I could add $replace=false option on the Linux server, but I am
 trying
 to understand the different behavior of header() function on these
 two
 servers. Any thoughts?

Well, according to the manual, you need to be using the FALSE parameter anyway 
since By default it will replace, but if you pass in FALSE as the second 
argument you can force multiple headers. So the wrong behaviour is on the 
(older) OS X server, but I'm as confused as you as to why this should be as 
there is no indication in the manual or the ChangeLog that the default 
behaviour has changed at any point.

Cheers!

Mike
-- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, Portland PD507, City Campus, 
Portland Way, LEEDS,  LS1 3HE,  United Kingdom 
E: m.f...@leedsmet.ac.uk T: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] header function odd behavior

2011-06-27 Thread Nilesh Govindarajan
On 06/28/2011 09:10 AM, H Rao wrote:
 Hi,

 I am trying to understand odd(different) behavior of the header function
 under two different environments.

 Here is the code which I am trying to execute from two different servers

 ?
 header (Set-Cookie: c1=value1;path=/; domain=.domain.com);
 header (Set-Cookie: c2=value2;path=/; domain=.domain.com);
 ?

 When executed from server1(OS X), both cookies are set in browser, but when
 executed from server2(Linux), only the second cookie is set.

 server1 and server2 are running different OS and php version as below. I
 know I could add $replace=false option on the Linux server, but I am trying
 to understand the different behavior of header() function on these two
 servers. Any thoughts?

snip

I don't have a clear idea about this because I always use setcookie(),
but something tells me that this has something to do with output
buffering and friends.

-- 
Regards,
Nilesh Govindarajan
@nileshgr


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



[PHP] Re: PHP - Header ERROR

2010-06-13 Thread Shawn McKenzie
On 06/13/2010 08:43 AM, Don Wieland wrote:
 Hello,
 
 I have a contact form with three fields, name, email, and comment, and a
 CAPTCHA
 
 I am doing some basic validation for empty fields but am getting a PHP
 error when trying to redirect back to the original page with an ERROR,
 
 It seems when my COMMENT field contains BRs, it generates the PHP
 ERROR. No BR?s works perfectly. Am I missing a function for the comment
 that is necessary for the GET STRING return?
 
 if($_POST['name'] AND $_POST['email'] AND $_POST['comment']) {
 }else{
 header(location: contactus.php?Error=Missing values in REQUIRED
 FIELDSname=.$_POST['name'].email=.$_POST['email'].comment=.$_POST['comment']);
 
 exit();
 }
 
 
 session_start();
 
 
 
 if($_SESSION['Captcha_Str'] != $_POST['scode']) {
 echo HI;
 header(location: contactus.php?Error=You did not enter your SECURITY
 CODE correctly. It is case
 sensitive.name=.$_POST['name'].email=.$_POST['email'].comment=.$_POST['comment']);
 
 exit();
 }
 
 
 Don Wieland
 D W   D a t a   C o n c e p t s
 ~
 d...@dwdataconcepts.com
 Direct Line - (949) 305-2771
 
 Integrated data solutions to fit your business needs.
 
 Need assistance in dialing in your FileMaker solution? Check out our
 Developer Support Plan at:
 http://www.dwdataconcepts.com/DevSup.html
 
 Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro 9
 or higher
 http://www.appointment10.com
 
 For a quick overview -
 http://www.appointment10.com/Appt10_Promo/Overview.html
 
 

You still haven't given us what ERROR you receive, but you need to
urlencode() $_POST['comment'] and the other values in the URL query string.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Re: PHP - Header ERROR

2010-06-13 Thread Steve

On 6/13/2010 9:37 AM, Shawn McKenzie wrote:

On 06/13/2010 08:43 AM, Don Wieland wrote:
   

Hello,

I have a contact form with three fields, name, email, and comment, and a
CAPTCHA

I am doing some basic validation for empty fields but am getting a PHP
error when trying to redirect back to the original page with an ERROR,

It seems when my COMMENT field containsBRs, it generates the PHP
ERROR. NoBR?s works perfectly. Am I missing a function for the comment
that is necessary for the GET STRING return?

if($_POST['name'] AND $_POST['email'] AND $_POST['comment']) {
}else{
header(location: contactus.php?Error=Missing values in REQUIRED
FIELDSname=.$_POST['name'].email=.$_POST['email'].comment=.$_POST['comment']);

exit();
}


session_start();



if($_SESSION['Captcha_Str'] != $_POST['scode']) {
echo HI;
header(location: contactus.php?Error=You did not enter your SECURITY
CODE correctly. It is case
sensitive.name=.$_POST['name'].email=.$_POST['email'].comment=.$_POST['comment']);

exit();
}


Don Wieland
D W   D a t a   C o n c e p t s
~
d...@dwdataconcepts.com
Direct Line - (949) 305-2771

Integrated data solutions to fit your business needs.

Need assistance in dialing in your FileMaker solution? Check out our
Developer Support Plan at:
http://www.dwdataconcepts.com/DevSup.html

Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro 9
or higher
http://www.appointment10.com

For a quick overview -
http://www.appointment10.com/Appt10_Promo/Overview.html


 

You still haven't given us what ERROR you receive, but you need to
urlencode() $_POST['comment'] and the other values in the URL query string.

   


echo HI;
header(...

This part will cause an error since outputting anything will cause the 
headers to be sent (unless output buffering is on). Once sent, the 
headers cannot be modified.


You should also think about using urlencode on the values being sent in 
the redirect URLs, or even using a code to reference each error.


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



Re: [PHP] Header function

2010-03-01 Thread Kim Madsen

Ashley Sheridan wrote on 01/03/2010 07:13:


The HTTP header doesn't treat quoteation marks in the same way that PHP
does. It needs double quote marks to function correctly.


How do you mean? And do you have a link to this information?

Even if this is true, then the first Nick did should still be correct?

header('Content-Disposition: attachment; filename=PurchaseReq.doc');

I'm using the same headers for downloads, allthough I use double qoutes 
for the header function aswell:


header(Content-Disposition: attachment; filename=\artist - title.mp3\);

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Header function

2010-03-01 Thread Ashley Sheridan
On Mon, 2010-03-01 at 12:14 +0100, Kim Madsen wrote:

 Ashley Sheridan wrote on 01/03/2010 07:13:
 
  The HTTP header doesn't treat quoteation marks in the same way that PHP
  does. It needs double quote marks to function correctly.
 
 How do you mean? And do you have a link to this information?
 
 Even if this is true, then the first Nick did should still be correct?
 
 header('Content-Disposition: attachment; filename=PurchaseReq.doc');
 
 I'm using the same headers for downloads, allthough I use double qoutes 
 for the header function aswell:
 
 header(Content-Disposition: attachment; filename=\artist - title.mp3\);
 
 -- 
 Kind regards
 Kim Emax - masterminds.dk
 


I only meant for the quotes around the filename. I'd tried

header(Content-Disposition: attachment; filename='artist -
title.mp3');

before and it didn't work correctly. I hadn't run into the problem of
double quotes inside singe though, as the filenames I was generating
relied on a variable, and I found it easier to just escape the second
set of nested quotes and include the variable directly.

As far as I'm aware, the header() function shouldn't care whether it
uses single or double quotes, so I would assume it's something else
amiss.

Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] Header function

2010-02-28 Thread Ashley Sheridan
On Sat, 2010-02-27 at 23:48 +1100, Nick allan wrote:

 Interesting the following works
 Changing the  to '. If I leave the ' around the filename, the ' becomes part 
 of the filename. But it seemed to be more about changing the surrounding ' to 
  that fixed it. Not sure why this is, but its working now.
 
 
 header('Content-Type: application/msword');
  header(Content-Disposition: attachment; filename=PurchaseReq.doc);
 -Original Message-
 From: Richard Quadling [mailto:rquadl...@googlemail.com] 
 Sent: Saturday, 27 February 2010 8:45 PM
 To: Nick allan
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Header function
 
 On 27 February 2010 04:32, Nick allan nal...@wdev.net wrote:
  Hi all
 
  Has anyone got any ideas why the following isn't giving me correct filename
  in the ie save dialogue
 
  header('Content-Type: application/msword');
 
   header('Content-Disposition: attachment; filename=PurchaseReq.doc');
 
 
 
  I get the save dialogue, but with preq.doc instead of PurchaseReq.doc
 
  Preq.php is the calling php file. It has worked before so I'm not sure what
  I've changed to have it stop working.
 
 
 
 
 
  Thanks in advance for any suggestions.
 
 
 
  Regards Nick
 
 
 
 
 
 What happens if you drop the quotes around the filename?
 
 -- 
 -
 Richard Quadling
 Standing on the shoulders of some very clever giants!
 EE : http://www.experts-exchange.com/M_248814.html
 EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
 Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
 ZOPA : http://uk.zopa.com/member/RQuadling
 
 


The HTTP header doesn't treat quoteation marks in the same way that PHP
does. It needs double quote marks to function correctly.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Header function

2010-02-27 Thread Richard Quadling
On 27 February 2010 04:32, Nick allan nal...@wdev.net wrote:
 Hi all

 Has anyone got any ideas why the following isn't giving me correct filename
 in the ie save dialogue

 header('Content-Type: application/msword');

  header('Content-Disposition: attachment; filename=PurchaseReq.doc');



 I get the save dialogue, but with preq.doc instead of PurchaseReq.doc

 Preq.php is the calling php file. It has worked before so I'm not sure what
 I've changed to have it stop working.





 Thanks in advance for any suggestions.



 Regards Nick





What happens if you drop the quotes around the filename?

-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



RE: [PHP] Header function

2010-02-27 Thread Nick allan
Interesting the following works
Changing the  to '. If I leave the ' around the filename, the ' becomes part 
of the filename. But it seemed to be more about changing the surrounding ' to  
that fixed it. Not sure why this is, but its working now.


header('Content-Type: application/msword');
 header(Content-Disposition: attachment; filename=PurchaseReq.doc);
-Original Message-
From: Richard Quadling [mailto:rquadl...@googlemail.com] 
Sent: Saturday, 27 February 2010 8:45 PM
To: Nick allan
Cc: php-general@lists.php.net
Subject: Re: [PHP] Header function

On 27 February 2010 04:32, Nick allan nal...@wdev.net wrote:
 Hi all

 Has anyone got any ideas why the following isn't giving me correct filename
 in the ie save dialogue

 header('Content-Type: application/msword');

  header('Content-Disposition: attachment; filename=PurchaseReq.doc');



 I get the save dialogue, but with preq.doc instead of PurchaseReq.doc

 Preq.php is the calling php file. It has worked before so I'm not sure what
 I've changed to have it stop working.





 Thanks in advance for any suggestions.



 Regards Nick





What happens if you drop the quotes around the filename?

-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling


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



Re: [PHP] header function query

2010-02-26 Thread Richard Quadling
On 26 February 2010 06:49, Nick allan nal...@wdev.net wrote:
 Hi all

 The situation is as follows

 I've read some data in from a couple of files into a string variable, made
 some changes to it and want to send the contents of the string out to the
 browser as a word document.

 My code currently looks like the following

 header('Content-Type: application/msword');

                header('Content-Disposition: attachment;
 filename=preq.doc');

 ob_clean();

 echo $allText;





 The above code works fine, the client gets a file download dialogue and can
 save or open the file.

 How can I indicate end of file, then continue writing html to display a new
 page. I want to be able to ask the user some additional questions after they
 have downloaded the file.  My problem is that if I add any html code after
 the above echo statement, it is included in the downloaded file.

 There's probably a simple answer to this, but I haven't been able to find
 anything using google.



 Thanks in advance for any suggestions.



 Regards Nick





Under normal conditions, you can't.

A request is for a single thing. While it is potentially possible to
embed graphics, css, js into a single html file request, downloading
files is not.

Instead, you issue the html first, but include in the head tag, a
meta redirect tag to the URL just for the download file.




-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] header function query

2010-02-26 Thread Rene Veerman
output the html you want to send afterwards first,

then either put a link to another script that outputs the word file,
or have an auto-launch ajax routine (i recommend jquery.com for ajax)
do it automatically.

On Fri, Feb 26, 2010 at 7:49 AM, Nick allan nal...@wdev.net wrote:
 Hi all

 The situation is as follows

 I've read some data in from a couple of files into a string variable, made
 some changes to it and want to send the contents of the string out to the
 browser as a word document.

 My code currently looks like the following

 header('Content-Type: application/msword');

                header('Content-Disposition: attachment;
 filename=preq.doc');

 ob_clean();

 echo $allText;





 The above code works fine, the client gets a file download dialogue and can
 save or open the file.

 How can I indicate end of file, then continue writing html to display a new
 page. I want to be able to ask the user some additional questions after they
 have downloaded the file.  My problem is that if I add any html code after
 the above echo statement, it is included in the downloaded file.

 There's probably a simple answer to this, but I haven't been able to find
 anything using google.



 Thanks in advance for any suggestions.



 Regards Nick





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



Re: [PHP] header(Location:...) fails

2010-01-14 Thread haliphax
On Wed, Jan 13, 2010 at 7:02 PM, Shawn McKenzie nos...@mckenzies.netwrote:

 Robert Cummings wrote:
  Just make your life easy and create a redirect() function that generates
  the header instruction, makes a relative URL into an absolute URL and
  does the exit call. Then you just need to do:
 
  redirect( 'target.php' );
 
  So much simpler :)
 
  Cheers,
  Rob.

 Definitely!  Technically, header() with Location: should have an
 absolute URL, though it works without one most of the time.

 --
 Thanks!
 -Shawn
 http://www.spidean.com

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


Also, when in doubt, I find it's usually a good idea to check the output
being sent with a more low-level tool, such as Fiddler, so that you can view
the raw values rather than leaving it up to your browser to interpret them.


// Todd


Re: [PHP] header(Location:...) fails

2010-01-13 Thread Bruno Fajardo
2010/1/13 Richard S. Crawford rscrawf...@mossroot.com

 Here is a snippet of code that is going to be the death of me:

 
 //  Create a new project
 $projectcode = strtoupper(addslashes($_POST['projectcode']));   //  project
 code

 //  Make sure the project code is unique
 if (!$existingproject = mysql_query(select * from pb_versions where
 projectcode like '.strtoupper($projectcode).')) {
    die (Could not check for existing project code!br /.mysql_error());
 }

 $numprojects = mysql_num_rows($existingproject);

 if ($numprojects  0) {
    $pid = mysql_result($existingproject,0,versionID);
    header(Location:managebudget.php?e=1pid=$pid);
 }
 

 Now, even if $numprojects is 1, 2, 3, etc., the header() command is not
 executed. Strangely, a header(Location) command later on in the script
 *is* executed. I've output the value of $numprojects, so I know that it's
 greater than 0, so the command
 header(Location:managebudget.php?e=1pid=$pid); *should* be executed...
 but it isn't. (Weirdly, if I put a die() command *after* this header()
 command, it works... but it seems pathologically inelegant to do so.)

There's nothing in wrong in putting a die command after the
header(Location). In fact, it is common. The header() command by
itself don't imply in the send of the request. You can have many
header() commands in sequence, and the header will be sent only in the
end of the process.

Cheers,
Bruno.


 Obviously, I'm missing something incredibly basic. Can anyone help me figure
 this out?


 --
 Richard S. Crawford (rscrawf...@mossroot.com)
 http://www.mossroot.com
 Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)

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



Re: [PHP] header(Location:...) fails

2010-01-13 Thread Andrew Ballard
On Wed, Jan 13, 2010 at 2:39 PM, Richard S. Crawford
rscrawf...@mossroot.com wrote:
 Now, even if $numprojects is 1, 2, 3, etc., the header() command is not
 executed. Strangely, a header(Location) command later on in the script
 *is* executed. I've output the value of $numprojects, so I know that it's
 greater than 0, so the command
 header(Location:managebudget.php?e=1pid=$pid); *should* be executed...
 but it isn't. (Weirdly, if I put a die() command *after* this header()
 command, it works... but it seems pathologically inelegant to do so.)

 Obviously, I'm missing something incredibly basic. Can anyone help me figure
 this out?

It isn't pathologically inelegant at all. All the header function
does is output the header; it does not stop script execution. If you
don't stop the script yourself, it will continue to execute. You
probably want to send a message right after the header call anyway,
just in case someone is using a browser that does not handle
redirection.

Andrew

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



Re: [PHP] header(Location:...) fails

2010-01-13 Thread Paul M Foster
On Wed, Jan 13, 2010 at 11:39:18AM -0800, Richard S. Crawford wrote:

 Here is a snippet of code that is going to be the death of me:
 
 
 //  Create a new project
 $projectcode = strtoupper(addslashes($_POST['projectcode']));   //  project
 code
 
 //  Make sure the project code is unique
 if (!$existingproject = mysql_query(select * from pb_versions where
 projectcode like '.strtoupper($projectcode).')) {
 die (Could not check for existing project code!br /.mysql_error());
 }
 
 $numprojects = mysql_num_rows($existingproject);
 
 if ($numprojects  0) {
 $pid = mysql_result($existingproject,0,versionID);
 header(Location:managebudget.php?e=1pid=$pid);
 }
 
 
 Now, even if $numprojects is 1, 2, 3, etc., the header() command is not
 executed. Strangely, a header(Location) command later on in the script
 *is* executed. I've output the value of $numprojects, so I know that it's
 greater than 0, so the command
 header(Location:managebudget.php?e=1pid=$pid); *should* be executed...
 but it isn't. (Weirdly, if I put a die() command *after* this header()
 command, it works... but it seems pathologically inelegant to do so.)
 
 Obviously, I'm missing something incredibly basic. Can anyone help me figure
 this out?

For one thing, I'd put a space after Location: in the header() call.
But I've found that this call will sometimes fail (or *look* like it
fails) unless you put something like exit(); after it. This terminates
execution and forces the script to transfer control as it should. Just
make it a habit to always include and exit(); call after your final
header() call.

Paul

-- 
Paul M. Foster

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



Re: [PHP] header(Location:...) fails

2010-01-13 Thread Robert Cummings

Paul M Foster wrote:

On Wed, Jan 13, 2010 at 11:39:18AM -0800, Richard S. Crawford wrote:


Here is a snippet of code that is going to be the death of me:


//  Create a new project
$projectcode = strtoupper(addslashes($_POST['projectcode']));   //  project
code

//  Make sure the project code is unique
if (!$existingproject = mysql_query(select * from pb_versions where
projectcode like '.strtoupper($projectcode).')) {
die (Could not check for existing project code!br /.mysql_error());
}

$numprojects = mysql_num_rows($existingproject);

if ($numprojects  0) {
$pid = mysql_result($existingproject,0,versionID);
header(Location:managebudget.php?e=1pid=$pid);
}


Now, even if $numprojects is 1, 2, 3, etc., the header() command is not
executed. Strangely, a header(Location) command later on in the script
*is* executed. I've output the value of $numprojects, so I know that it's
greater than 0, so the command
header(Location:managebudget.php?e=1pid=$pid); *should* be executed...
but it isn't. (Weirdly, if I put a die() command *after* this header()
command, it works... but it seems pathologically inelegant to do so.)

Obviously, I'm missing something incredibly basic. Can anyone help me figure
this out?


For one thing, I'd put a space after Location: in the header() call.
But I've found that this call will sometimes fail (or *look* like it
fails) unless you put something like exit(); after it. This terminates
execution and forces the script to transfer control as it should. Just
make it a habit to always include and exit(); call after your final
header() call.


Just make your life easy and create a redirect() function that generates 
the header instruction, makes a relative URL into an absolute URL and 
does the exit call. Then you just need to do:


redirect( 'target.php' );

So much simpler :)

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] header(Location:...) fails

2010-01-13 Thread Shawn McKenzie
Robert Cummings wrote:
 Just make your life easy and create a redirect() function that generates
 the header instruction, makes a relative URL into an absolute URL and
 does the exit call. Then you just need to do:
 
 redirect( 'target.php' );
 
 So much simpler :)
 
 Cheers,
 Rob.

Definitely!  Technically, header() with Location: should have an
absolute URL, though it works without one most of the time.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Header problem - SOLVED

2009-10-19 Thread Kim Madsen
This has been solved today. Talawa had a similar problem and came up 
with a solution to his problem, namely using session_write_close() 
before creating the headers. That stunt also solved my problem :-)


--
Kind regards
Kim Emax

Kim Madsen wrote on 2009-10-03 13:30:

Hi PHP people

I have a really strange and annoying problem. I've got a site, where
members can download music. User clicks index.php (in index.php
there's an iframe, that opens another file), if certain check are okay
then a popup window opens download.php, where a mp3 file is fetched
from the server and renamed in the header, then pushed to the enduser,
this works fine. But now I want to create zipfiles too but when a user
downloads a zipfile it's like the whole site is freezed until download
has completed. My guess is that this is some sort of header problem
(see headers below), due to three headers at the same time, cause the
class works as expected in the test page i've created. Inputs to
correct headers would be appriciated very much :-)

Mp3 headers:
 $new_filename = attachment; filename=\{$artist} - {$title}.mp3\;
 header('Content-Description: File Transfer');
 header(Content-Type: application/octet-stream);
 header(Content-Length: $size);
 header(Content-Disposition: $new_filename);
 header(Content-Transfer-Encoding: binary);
 readfile($source_file);

Zip headers:
 $zip = new zipfile();
 $zip-add_dir(.);
 $new_filename= {$artist} - {$title}.mp3;
 if(mysql_num_rows($result)) {
   $zip-add_file($file, $new_filename);
 }
 header(Pragma: public);
 header(Expires: 0);
 header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
 header(Cache-Control: private,false);
 header(Content-type: application/zip);
 #header(Content-Type: application/octet-stream);
 header(Content-disposition: attachment; filename=\zipTest.zip\);
 header('Content-Transfer-Encoding: binary');
 ob_end_clean();
 echo $zip-file();

Code example: http://lps.netlinq.dk/test010/test_zip.class.php

Headers (fetched with firefox add-on: live http headers)

This is headers from the site, where the problem occurs:

1. click on the link to a title (Maxwell in this case)
--
http://lps.netlinq.dk/?action=downloadtrack_id=357

GET /?action=downloadtrack_id=357 HTTP/1.1
Host: lps.netlinq.dk
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/
20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://lps.netlinq.dk/?action=downloadtrack_id=350
Cookie: login_email=kim%40emax.dk;
PHPSESSID=fbb5d6adec802766cf6f638c99ab4f1d

HTTP/1.x 200 OK
Date: Fri, 02 Oct 2009 15:15:21 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g
X-Powered-By: PHP/5.2.4-2ubuntu5.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 4250
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html

2. I click on download zip (this is a link to index.php)
if conditions are met, then a popup with download.php is activated and
here a zip header is made

--
http://lps.netlinq.dk/index.php

POST /index.php HTTP/1.1
Host: lps.netlinq.dk
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/
20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://lps.netlinq.dk/?action=downloadtrack_id=357
Cookie: login_email=kim%40emax.dk;
PHPSESSID=fbb5d6adec802766cf6f638c99ab4f1d
Content-Type: application/x-www-form-urlencoded
Content-Length: 131
action=ask_questionsdownload_zipfile=1version_id
%5B1065%5D=1version_id%5B1066%5D=1version_id%5B1067%5D=1version_id
%5B1068%5D=1

HTTP/1.x 200 OK
Date: Fri, 02 Oct 2009 15:15:29 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g
X-Powered-By: PHP/5.2.4-2ubuntu5.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 3216
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Content-Type: text/html
--
http://lps.netlinq.dk/download.php?track_id=357member_id=1string=41e0cd250ca3a40598e2019fd4c813cckbit=320zipfile=1 



GET /download.php?

Re: [PHP] Header problem - solved

2009-10-16 Thread Kim Madsen

Andrea Giammarchi wrote on 2009-10-05 18:26:


  There's a useful function called headers_sent() which checks to see if
  the headers have already been sent to the browser. This might be a good
  place to throw into your code at various points to check and see if
  something is being written which you don't expect.

true, check that as well, moreover, you talked about utf-8, well, if the 
BOM is automatically added, it can cause lots of problems ... still, 
only if you sent whatever to the output before the download.


I've tried a bunch of things, including link to index.php and as first 
thing check if the request is a zipfile, then throw a zip header, 
readfile the file then exit the code. Nothing helped. So I figured it 
could be a latin-1 / utf-8 problem and tried to post to a fresh new page 
(donwload_zip.php) instead, where I was sure the terminal and Vi was set 
to use latin-1, then it worked.


It's still not the ultimate solution as we wanted the zipfile to be 
created on the fly in memory in order not to have to delete files 
afterwards and to be sure that only allowed users can fetch the files 
(of course you can always put the zipfiles outside webscope, but still...)


--
Kind regards
Kim Emax

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



Re: [PHP] Header problem

2009-10-05 Thread Kim Madsen

Hi Andrea

Andrea Giammarchi wrote on 2009-10-04 19:36:
Unless I am missing something, your page has too many if and it always 
ends up with print something ... but there is no exit after the 
download, so the zip will have extra output included without a reason 
... which is an error, imho, dunno how else explain if you can't see 
your print links at the end of the page ...


Sorry, the .phps file wasn't updated, but the page still works as 
expected even though I've printed stuff after the header (i tested that 
just for fun).


I'm thinking I'll try and look at the included files, this is what 
happends before the headers are trown:


session_start();
$version_id = $_REQUEST['version_id'];
$track_id = $_REQUEST['track_id'];
$member_id = $_REQUEST['member_id'];
$string = $_REQUEST['string'];
$zipfile = $_REQUEST['zipfile'];

if($DOWNLOAD_OK) {
  include inc/connect.inc;
  include inc/functions.inc;
  include inc/default_functions.inc;

As you said earlier, spaces could do wierd stuff to a header

Also switching between utf-8 and latin-1 character sets can make php 
choke, I've experienced that before with sessions.


Kind regards
Kim


  Date: Sun, 4 Oct 2009 19:09:35 +0200
  From: php@emax.dk
  To: php-general@lists.php.net
  Subject: Re: [PHP] Header problem
 
  Hello Andrea
 
  Andrea Giammarchi wrote on 2009-10-04 18:49:
  
Header must come first (before you output anything) or you get a 
parse

error
  
   I try to better explain ...
  
   HTTP works like this: you ask something, you receive something, 
html and

   texts are just one option.
 
  Got it so far
 
   Your example page mess up html, zip, everything, because when you
   download a file you still have the rest of the page sent in the output.
 
  Nops, not really.
 
  index.php:
  print stuff
  do stuff
  open download.php in a _new_ window.
  print more stuff
  page end
 
  this should be possible, right? Two different headers for two different
  pages.
 
   A download should have ONLY file related info/headers and nothing else
   in the output ... echo/print in the middle of the code before an 
header

   is an error, everything in output before an header is an error,
   everything after headers that is not related to that header is an 
error,

   got my point?
 
  Jep! And that's actually what I do. What I could, is to add exit; after
  the headers have been sent and the file have been pushed. I do an update
  of the database to tell the system that the files in the zipfile has
  been downloaded.
 
   To decide how a page should behave, you must be able to do not produce
   anything except the expected output with expected headers, that's 
why I

   have said headers are fundamental for a response, we cannot play with
   outputs however we want.
 
  The only output is the headers of the zipfile:
 
  header('Accept-Ranges: bytes');
  header(Content-Type: application/zip);
  header(Content-Length: $size);
  header(Content-disposition: attachment;
  filename=\.basename($zip_filename).\);
  header(Content-Transfer-Encoding: binary);
  readfile($filename);
 
  // we need to reload top5 to have a current view
  unset($_SESSION['top5']);
  $_SESSION['reload_top5'] = 1;
 
  // NOTE second param shall be an array, not a variable when
  downloading zip files
  download_completed($member_id, $downloaded_version_ids);
 
  Wouldn't you say this is okay?
 
   As summary, once you have created and tried a dedicated page without a
   single white space or print before, during, or after the dedicated
   download stuff, I'll try to understand where is the error.
   Otherwise it could be everything, and I am against magic 
behaviors ...
   you need to download? Well, create a file which aims id to download 
and

   nothing else, or you gonna constantly find these kind of problems in
   your applications.
 
  I believe the testpage does forfill that request? Or do you mean 
otherwise?

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


Windows Live Hotmail: Your friends can get your Facebook updates, right 
from Hotmail®. 
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009



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



Re: [PHP] Header problem

2009-10-05 Thread Ashley Sheridan
On Mon, 2009-10-05 at 18:10 +0200, Kim Madsen wrote:

 Hi Andrea
 
 Andrea Giammarchi wrote on 2009-10-04 19:36:
  Unless I am missing something, your page has too many if and it always 
  ends up with print something ... but there is no exit after the 
  download, so the zip will have extra output included without a reason 
  ... which is an error, imho, dunno how else explain if you can't see 
  your print links at the end of the page ...
 
 Sorry, the .phps file wasn't updated, but the page still works as 
 expected even though I've printed stuff after the header (i tested that 
 just for fun).
 
 I'm thinking I'll try and look at the included files, this is what 
 happends before the headers are trown:
 
 session_start();
 $version_id = $_REQUEST['version_id'];
 $track_id = $_REQUEST['track_id'];
 $member_id = $_REQUEST['member_id'];
 $string = $_REQUEST['string'];
 $zipfile = $_REQUEST['zipfile'];
 
 if($DOWNLOAD_OK) {
include inc/connect.inc;
include inc/functions.inc;
include inc/default_functions.inc;
 
 As you said earlier, spaces could do wierd stuff to a header
 
 Also switching between utf-8 and latin-1 character sets can make php 
 choke, I've experienced that before with sessions.
 
 Kind regards
 Kim
 
Date: Sun, 4 Oct 2009 19:09:35 +0200
From: php@emax.dk
To: php-general@lists.php.net
Subject: Re: [PHP] Header problem
   
Hello Andrea
   
Andrea Giammarchi wrote on 2009-10-04 18:49:

  Header must come first (before you output anything) or you get a 
  parse
  error

 I try to better explain ...

 HTTP works like this: you ask something, you receive something, 
  html and
 texts are just one option.
   
Got it so far
   
 Your example page mess up html, zip, everything, because when you
 download a file you still have the rest of the page sent in the output.
   
Nops, not really.
   
index.php:
print stuff
do stuff
open download.php in a _new_ window.
print more stuff
page end
   
this should be possible, right? Two different headers for two different
pages.
   
 A download should have ONLY file related info/headers and nothing else
 in the output ... echo/print in the middle of the code before an 
  header
 is an error, everything in output before an header is an error,
 everything after headers that is not related to that header is an 
  error,
 got my point?
   
Jep! And that's actually what I do. What I could, is to add exit; after
the headers have been sent and the file have been pushed. I do an update
of the database to tell the system that the files in the zipfile has
been downloaded.
   
 To decide how a page should behave, you must be able to do not produce
 anything except the expected output with expected headers, that's 
  why I
 have said headers are fundamental for a response, we cannot play with
 outputs however we want.
   
The only output is the headers of the zipfile:
   
header('Accept-Ranges: bytes');
header(Content-Type: application/zip);
header(Content-Length: $size);
header(Content-disposition: attachment;
filename=\.basename($zip_filename).\);
header(Content-Transfer-Encoding: binary);
readfile($filename);
   
// we need to reload top5 to have a current view
unset($_SESSION['top5']);
$_SESSION['reload_top5'] = 1;
   
// NOTE second param shall be an array, not a variable when
downloading zip files
download_completed($member_id, $downloaded_version_ids);
   
Wouldn't you say this is okay?
   
 As summary, once you have created and tried a dedicated page without a
 single white space or print before, during, or after the dedicated
 download stuff, I'll try to understand where is the error.
 Otherwise it could be everything, and I am against magic 
  behaviors ...
 you need to download? Well, create a file which aims id to download 
  and
 nothing else, or you gonna constantly find these kind of problems in
 your applications.
   
I believe the testpage does forfill that request? Or do you mean 
  otherwise?
   
Kind regards
Kim
   
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
   
  
  
  Windows Live Hotmail: Your friends can get your Facebook updates, right 
  from Hotmail®. 
  http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009
 
 

There's a useful function called headers_sent() which checks to see if
the headers have already been sent to the browser. This might be a good
place to throw into your code at various points to check and see if
something is being written which you don't expect.

Also, one method I use, is to write the content you would be 'printing

RE: [PHP] Header problem

2009-10-05 Thread Andrea Giammarchi


 There's a useful function called headers_sent() which checks to see if
 the headers have already been sent to the browser. This might be a good
 place to throw into your code at various points to check and see if
 something is being written which you don't expect.

true, check that as well, moreover, you talked about utf-8, well, if the BOM is 
automatically added, it can cause lots of problems ... still, only if you sent 
whatever to the output before the download.
  
_
Windows Live: Keep your friends up to date with what you do online.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010

Re: [PHP] Header problem

2009-10-04 Thread Kim Madsen

Andrea Giammarchi wrote on 2009-10-03 13:40:
 Do you want users download the file or the zip?

They can choose between the two.

 do you send other headers before the download?

Header must come first (before you output anything) or you get a parse 
error, so I'm not sure what you mean here? You can see the source of the 
class at the testpage I linked to.


 It's quite a common error to set a default header in PHP at the 
beginning of whatever application, while header should be used as last 
exit point and never in the middle, or at the beginning, of a response.


I'm not sure what you mean by this? My download.php first checks for the 
relevant data is there (track_id/version_id, a session with member_id), 
then if the download is allowed (by access or if it has already been 
downloaded) then it fetches the relevant files, zip these to the disk 
and first then... creates the zip header and afterwards uses a readfile 
on the zipfile just created.


 Moreover, if you use readfile and then zip what do you expect, 
multiple downloads in one? This is not how HTTP work ... so please show 
more php, or explain better what you would like to do.


What do you need to see besides the testpage?

If I have 4 mp3 files of 5mb each, these will be zipped into one 20mb 
file, and that is of course only one download. That's the wish from the 
siteowner: easier download of several mixes of the same artist/track


I hope this makes the problem more clear to you :-)

I've debugged some more into the problem, this is a header of a zip 
download where the site works as expected:


HTTP/1.x 200 OK
Date: Sat, 03 Oct 2009 22:26:45 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch 
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g

X-Powered-By: PHP/5.2.4-2ubuntu5.6
Accept-Ranges: bytes
Content-Length: 7083675
Content-Disposition: attachment; filename=Maxwell - Bad Habits 
(Remixes) (index.php=get_zip).zip

Content-Transfer-Encoding: binary
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: application/zip

I call the file like this: index.php?get_zip=test_output.zip

index.php does this:

  $new_zipfile .= $_SESSION['download_title']..zip;
/*
  header(Cache-Control: no-cache);
  header(Pragma: no-cache);
  header(Expires: now);
*/
  header('Accept-Ranges: bytes');
  header(Content-Type: application/zip);
  header(Content-Length: .filesize($archiveName));
  header(Content-Disposition: attachment; filename=\$new_zipfile\);
  header(Content-Transfer-Encoding: binary);

  readfile($archiveName);
  exit;

The outcommented headers was put in because I discovered that the 
download then was cached after giving the file a strange name, that name 
never occured in the download :-/ I've ended up by making a workaround 
by adding nocache=.microtime(). to the get_zip link but then the site 
freezes againg during the download, arrrghh...


And headers from the original zip solution in download.php, headers are 
set in function.inc, this is the output from Live HTTP headers:


HTTP/1.x 200 OK
Date: Sat, 03 Oct 2009 21:41:49 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch 
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g

X-Powered-By: PHP/5.2.4-2ubuntu5.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, 
pre-check=0

Pragma: no-cache
Accept-Ranges: bytes
Content-Length: 35756585
Content-Disposition: attachment; filename=Maxwell - Bad Habits 
(Remixes).zip

Content-Transfer-Encoding: binary
Keep-Alive: timeout=15, max=98
Connection: Keep-Alive
Content-Type: application/zip

difference to the returned zip headers in index.php is pragma, 
cache-control and expires, so I've removed these headers from the 
function, but they still show up:


HTTP/1.x 200 OK
Date: Sat, 03 Oct 2009 22:25:36 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch 
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g

X-Powered-By: PHP/5.2.4-2ubuntu5.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, 
pre-check=0

Pragma: no-cache
Accept-Ranges: bytes
Content-Length: 7083675
Content-Disposition: attachment; filename=Maxwell - Bad Habits 
(Remixes).zip

Content-Transfer-Encoding: binary
Keep-Alive: timeout=15, max=96
Connection: Keep-Alive
Content-Type: application/zip

So I think my problem is cache related in some way.

Kind regards
Kim


  Date: Sat, 3 Oct 2009 13:30:38 +0200
  From: php@emax.dk
  To: php-general@lists.php.net
  Subject: [PHP] Header problem
 
  Hi PHP people
 
  I have a really strange and annoying problem. I've got a site, where
  members can download music. User clicks index.php (in index.php
  there's an iframe, that opens another file), if certain check are okay
  then a popup window opens download.php, where a mp3 file is fetched
  from the server and renamed in the header, then pushed to the 

Re: [PHP] Header problem

2009-10-04 Thread Kim Madsen

Hi kranthi

kranthi wrote on 2009-10-03 16:21:
 Thats a lot of headers to read..
 At a first glance I can see that you did not specify a content-length
 header. this is a must and must be equal to the size of the file in
 bytes

I've noticed that too, but it's impossiple to determine the length of 
the zipfile, when creating the file in memory.


Instead I'm now writing the file to disk and uses filesize on the 
zipfile to get the length for Content-Length, then I use 
readfile(zipfile.zip) instead of echo $zip-file(); But the result is 
still the same :-/


Kind regards
Kim

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



Re: [PHP] Header problem

2009-10-04 Thread Ashley Sheridan
On Sun, 2009-10-04 at 18:10 +0200, Kim Madsen wrote:

 Hi kranthi
 
 kranthi wrote on 2009-10-03 16:21:
   Thats a lot of headers to read..
   At a first glance I can see that you did not specify a content-length
   header. this is a must and must be equal to the size of the file in
   bytes
 
 I've noticed that too, but it's impossiple to determine the length of 
 the zipfile, when creating the file in memory.
 
 Instead I'm now writing the file to disk and uses filesize on the 
 zipfile to get the length for Content-Length, then I use 
 readfile(zipfile.zip) instead of echo $zip-file(); But the result is 
 still the same :-/
 
 Kind regards
 Kim
 


Afaik, the content length header is not necessary, but it will cause
problems if it's set and it's wrong.

Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] Header problem

2009-10-04 Thread Andrea Giammarchi


 Header must come first (before you output anything) or you get a parse 
 error

I try to better explain ...

HTTP works like this: you ask something, you receive something, html and texts 
are just one option.

Your example page mess up html, zip, everything, because when you download a 
file you still have the rest of the page sent in the output.

A download should have ONLY file related info/headers and nothing else in the 
output ... echo/print in the middle of the code before an header is an error, 
everything in output before an header is an error, everything after headers 
that is not related to that header is an error, got my point?

To decide how a page should behave, you must be able to do not produce anything 
except the expected output with expected headers, that's why I have said 
headers are fundamental for a response, we cannot play with outputs however we 
want. 

As summary, once you have created and tried a dedicated page without a single 
white space or print before, during, or after the dedicated download stuff, 
I'll try to understand where is the error.
Otherwise it could be everything, and I am against magic behaviors ... you 
need to download? Well, create a file which aims id to download and nothing 
else, or you gonna constantly find these kind of problems in your applications.

Regards
  
_
Keep your friends updated—even when you’re not signed in.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010

RE: [PHP] Header problem

2009-10-04 Thread Andrea Giammarchi


 Afaik, the content length header is not necessary, but it will cause
 problems if it's set and it's wrong.

correct, missed Content-Length means the classic download with useless progress 
bar and undefined estimation time, problematic for preloader as well in case of 
images, swf, generic data, etc.

Content_length should be always present and it should be correct, but obviously 
if there are print or echo or other outputs non file related, Content-Length 
can simply mess up the response.
  
_
Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail 
you.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010

Re: [PHP] Header problem

2009-10-04 Thread Kim Madsen

Hello Andrea

Andrea Giammarchi wrote on 2009-10-04 18:49:


  Header must come first (before you output anything) or you get a parse
  error

I try to better explain ...

HTTP works like this: you ask something, you receive something, html and 
texts are just one option.


Got it so far

Your example page mess up html, zip, everything, because when you 
download a file you still have the rest of the page sent in the output.


Nops, not really.

index.php:
print stuff
do stuff
open download.php in a _new_ window.
print more stuff
page end

this should be possible, right? Two different headers for two different 
pages.


A download should have ONLY file related info/headers and nothing else 
in the output ... echo/print in the middle of the code before an header 
is an error, everything in output before an header is an error, 
everything after headers that is not related to that header is an error, 
got my point?


Jep! And that's actually what I do. What I could, is to add exit; after 
the headers have been sent and the file have been pushed. I do an update 
of the database to tell the system that the files in the zipfile has 
been downloaded.


To decide how a page should behave, you must be able to do not produce 
anything except the expected output with expected headers, that's why I 
have said headers are fundamental for a response, we cannot play with 
outputs however we want.


The only output is the headers of the zipfile:

  header('Accept-Ranges: bytes');
  header(Content-Type: application/zip);
  header(Content-Length: $size);
  header(Content-disposition: attachment; 
filename=\.basename($zip_filename).\);

  header(Content-Transfer-Encoding: binary);
readfile($filename);

  // we need to reload top5 to have a current view
  unset($_SESSION['top5']);
  $_SESSION['reload_top5'] = 1;

  // NOTE second param shall be an array, not a variable when 
downloading zip files

  download_completed($member_id, $downloaded_version_ids);

Wouldn't you say this is okay?

As summary, once you have created and tried a dedicated page without a 
single white space or print before, during, or after the dedicated 
download stuff, I'll try to understand where is the error.
Otherwise it could be everything, and I am against magic behaviors ... 
you need to download? Well, create a file which aims id to download and 
nothing else, or you gonna constantly find these kind of problems in 
your applications.


I believe the testpage does forfill that request? Or do you mean otherwise?

Kind regards
Kim

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



RE: [PHP] Header problem

2009-10-04 Thread Andrea Giammarchi

Unless I am missing something, your page has too many if and it always ends up 
with print something ... but there is no exit after the download, so the zip 
will have extra output included without a reason ... which is an error, imho, 
dunno how else explain if you can't see your print links at the end of the 
page ... 

Regards

 Date: Sun, 4 Oct 2009 19:09:35 +0200
 From: php@emax.dk
 To: php-general@lists.php.net
 Subject: Re: [PHP] Header problem
 
 Hello Andrea
 
 Andrea Giammarchi wrote on 2009-10-04 18:49:
  
Header must come first (before you output anything) or you get a parse
error
  
  I try to better explain ...
  
  HTTP works like this: you ask something, you receive something, html and 
  texts are just one option.
 
 Got it so far
 
  Your example page mess up html, zip, everything, because when you 
  download a file you still have the rest of the page sent in the output.
 
 Nops, not really.
 
 index.php:
 print stuff
 do stuff
 open download.php in a _new_ window.
 print more stuff
 page end
 
 this should be possible, right? Two different headers for two different 
 pages.
 
  A download should have ONLY file related info/headers and nothing else 
  in the output ... echo/print in the middle of the code before an header 
  is an error, everything in output before an header is an error, 
  everything after headers that is not related to that header is an error, 
  got my point?
 
 Jep! And that's actually what I do. What I could, is to add exit; after 
 the headers have been sent and the file have been pushed. I do an update 
 of the database to tell the system that the files in the zipfile has 
 been downloaded.
 
  To decide how a page should behave, you must be able to do not produce 
  anything except the expected output with expected headers, that's why I 
  have said headers are fundamental for a response, we cannot play with 
  outputs however we want.
 
 The only output is the headers of the zipfile:
 
header('Accept-Ranges: bytes');
header(Content-Type: application/zip);
header(Content-Length: $size);
header(Content-disposition: attachment; 
 filename=\.basename($zip_filename).\);
header(Content-Transfer-Encoding: binary);
 readfile($filename);
 
// we need to reload top5 to have a current view
unset($_SESSION['top5']);
$_SESSION['reload_top5'] = 1;
 
// NOTE second param shall be an array, not a variable when 
 downloading zip files
download_completed($member_id, $downloaded_version_ids);
 
 Wouldn't you say this is okay?
 
  As summary, once you have created and tried a dedicated page without a 
  single white space or print before, during, or after the dedicated 
  download stuff, I'll try to understand where is the error.
  Otherwise it could be everything, and I am against magic behaviors ... 
  you need to download? Well, create a file which aims id to download and 
  nothing else, or you gonna constantly find these kind of problems in 
  your applications.
 
 I believe the testpage does forfill that request? Or do you mean otherwise?
 
 Kind regards
 Kim
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
  
_
Windows Live Hotmail: Your friends can get your Facebook updates, right from 
Hotmail®.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009

Re: [PHP] Header problem

2009-10-04 Thread Tommy Pham
 Original Message 
 From: Kim Madsen php@emax.dk
 To: php-general@lists.php.net
 Sent: Sun, October 4, 2009 9:10:36 AM
 Subject: Re: [PHP] Header problem
 
 Hi kranthi
 
 kranthi wrote on 2009-10-03 16:21:
  Thats a lot of headers to read..
  At a first glance I can see that you did not specify a content-length
  header. this is a must and must be equal to the size of the file in
  bytes
 
 I've noticed that too, but it's impossiple to determine the length of the 
 zipfile, when creating the file in memory.
 
 Instead I'm now writing the file to disk and uses filesize on the zipfile to 
 get 
 the length for Content-Length, then I use readfile(zipfile.zip) instead of 
 echo $zip-file(); But the result is still the same :-/
 
 Kind regards
 Kim
 
 -- PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

If you want to take advantage of chunked-transfer encoding, you can not specify 
'content-length'.


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



RE: [PHP] Header problem

2009-10-03 Thread Andrea Giammarchi

Do you want users download the file or the zip?

do you send other headers before the download?

It's
quite a common error to set a default header in PHP at the beginning of
whatever application, while header should be used as last exit point
and never in the middle, or at the beginning, of a response.

Moreover,
if you use readfile and then zip what do you expect, multiple downloads
in one? This is not how HTTP work ... so please show more php, or
explain better what you would like to do.

Regards

 Date: Sat, 3 Oct 2009 13:30:38 +0200
 From: php@emax.dk
 To: php-general@lists.php.net
 Subject: [PHP] Header problem
 
 Hi PHP people
 
 I have a really strange and annoying problem. I've got a site, where
 members can download music. User clicks index.php (in index.php
 there's an iframe, that opens another file), if certain check are okay
 then a popup window opens download.php, where a mp3 file is fetched
 from the server and renamed in the header, then pushed to the enduser,
 this works fine. But now I want to create zipfiles too but when a user
 downloads a zipfile it's like the whole site is freezed until download
 has completed. My guess is that this is some sort of header problem
 (see headers below), due to three headers at the same time, cause the
 class works as expected in the test page i've created. Inputs to
 correct headers would be appriciated very much :-)
 
 Mp3 headers:
   $new_filename = attachment; filename=\{$artist} - {$title}.mp3\;
   header('Content-Description: File Transfer');
   header(Content-Type: application/octet-stream);
   header(Content-Length: $size);
   header(Content-Disposition: $new_filename);
   header(Content-Transfer-Encoding: binary);
   readfile($source_file);
 
 Zip headers:
   $zip = new zipfile();
   $zip-add_dir(.);
   $new_filename= {$artist} - {$title}.mp3;
   if(mysql_num_rows($result)) {
 $zip-add_file($file, $new_filename);
   }
   header(Pragma: public);
   header(Expires: 0);
   header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
   header(Cache-Control: private,false);
   header(Content-type: application/zip);
   #header(Content-Type: application/octet-stream);
   header(Content-disposition: attachment; filename=\zipTest.zip\);
   header('Content-Transfer-Encoding: binary');
   ob_end_clean();
   echo $zip-file();
 
 Code example: http://lps.netlinq.dk/test010/test_zip.class.php
 
 Headers (fetched with firefox add-on: live http headers)
 
 This is headers from the site, where the problem occurs:
 
 1. click on the link to a title (Maxwell in this case)
 --
 http://lps.netlinq.dk/?action=downloadtrack_id=357
 
 GET /?action=downloadtrack_id=357 HTTP/1.1
 Host: lps.netlinq.dk
 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/
 20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
 *;q=0.8
 Accept-Language: en-us,en;q=0.5
 Accept-Encoding: gzip,deflate
 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
 Keep-Alive: 300
 Connection: keep-alive
 Referer: http://lps.netlinq.dk/?action=downloadtrack_id=350
 Cookie: login_email=kim%40emax.dk;
 PHPSESSID=fbb5d6adec802766cf6f638c99ab4f1d
 
 HTTP/1.x 200 OK
 Date: Fri, 02 Oct 2009 15:15:21 GMT
 Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
 mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g
 X-Powered-By: PHP/5.2.4-2ubuntu5.6
 Expires: Thu, 19 Nov 1981 08:52:00 GMT
 Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
 check=0
 Pragma: no-cache
 Vary: Accept-Encoding
 Content-Encoding: gzip
 Content-Length: 4250
 Keep-Alive: timeout=15, max=100
 Connection: Keep-Alive
 Content-Type: text/html
 
 2. I click on download zip (this is a link to index.php)
 if conditions are met, then a popup with download.php is activated and
 here a zip header is made
 
 --
 http://lps.netlinq.dk/index.php
 
 POST /index.php HTTP/1.1
 Host: lps.netlinq.dk
 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/
 20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
 *;q=0.8
 Accept-Language: en-us,en;q=0.5
 Accept-Encoding: gzip,deflate
 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
 Keep-Alive: 300
 Connection: keep-alive
 Referer: http://lps.netlinq.dk/?action=downloadtrack_id=357
 Cookie: login_email=kim%40emax.dk;
 PHPSESSID=fbb5d6adec802766cf6f638c99ab4f1d
 Content-Type: application/x-www-form-urlencoded
 Content-Length: 131
 action=ask_questionsdownload_zipfile=1version_id
 %5B1065%5D=1version_id%5B1066%5D=1version_id%5B1067%5D=1version_id
 %5B1068%5D=1
 
 HTTP/1.x 200 OK
 Date: Fri, 02 Oct 2009 15:15:29 GMT
 Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
 mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g
 X-Powered-By: PHP/5.2.4-2ubuntu5.6
 

Re: [PHP] Header problem

2009-10-03 Thread kranthi
Thats a lot of headers to read..
At a first glance I can see that you did not specify a content-length
header. this is a must and must be equal to the size of the file in
bytes

-- 
Kranthi.

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



[PHP] Re: PHP Header issue

2009-09-18 Thread Ralph Deffke
sorry man, but no blancs etc. means NOTHING should be send before the header

it should look like this:
?php 

header(Location: advertise2.php); 

?

here u can do ur html



not one! single char incl. space should be outputted before the header e.g. 
before the php open tag.



ralph_def...@yahoo.de



  Ernie Kemp ernie.k...@sympatico.ca wrote in message 
news:blu0-smtp35a2b5ec02eb211ecaa8b1f9...@phx.gbl...
   
  html 

  head 

  titleContact Us/title 

  /head 

  body 

  ?php header(Location: advertise2.php); ?

  /body 

  /html

  The above is just snippet of the code but even this simple example throws the 
Header Warning / Error.

   

  Warning: Cannot modify header information - headers already sent by (output 
started at /home/content/g/t/a /html/yourestate/advertise.php:6) 
in/home/content/g/t/a /html/yourestate/advertise.php on line 6

   

  The anwser may be simple but I have looked a blanks or spaces around the 
?php ? with no success.

  Ready need your help.

   

  Thanks,

  Ernie Kemp   

  Phone: 416 577 5565

  Email:   ek...@digitalbiz4u.com

   

  ...man will occasionally stumble over the truth, but usually manages to pick 
himself up, walk over or around it, and carry on.

  Winston S. Churchill 

   

   

   

   


Re: [PHP] Re: PHP Header issue

2009-09-18 Thread Ashley Sheridan
On Fri, 2009-09-18 at 19:01 +0200, Ralph Deffke wrote:
 sorry man, but no blancs etc. means NOTHING should be send before the header
 
 it should look like this:
 ?php 
 
 header(Location: advertise2.php); 
 
 ?
 
 here u can do ur html
 
 
 
 not one! single char incl. space should be outputted before the header e.g. 
 before the php open tag.
 
 
 
 ralph_def...@yahoo.de
 
 
 
   Ernie Kemp ernie.k...@sympatico.ca wrote in message 
 news:blu0-smtp35a2b5ec02eb211ecaa8b1f9...@phx.gbl...

   html 
 
   head 
 
   titleContact Us/title 
 
   /head 
 
   body 
 
   ?php header(Location: advertise2.php); ?
 
   /body 
 
   /html
 
   The above is just snippet of the code but even this simple example throws 
 the Header Warning / Error.
 

 
   Warning: Cannot modify header information - headers already sent by (output 
 started at /home/content/g/t/a /html/yourestate/advertise.php:6) 
 in/home/content/g/t/a /html/yourestate/advertise.php on line 6
 

 
   The anwser may be simple but I have looked a blanks or spaces around the 
 ?php ? with no success.
 
   Ready need your help.
 

 
   Thanks,
 
   Ernie Kemp   
 
   Phone: 416 577 5565
 
   Email:   ek...@digitalbiz4u.com
 

 
   ...man will occasionally stumble over the truth, but usually manages to 
 pick himself up, walk over or around it, and carry on.
   
 Winston S. Churchill 
 

 
I think this sort of issue arises particularly because of the
misconception that PHP is embedded inside HTML pages. Once a person has
that idea in their head, they will start to work with an HTML template
and add PHP as necessary. While that can work, in cases such as this,
it's best to remember that HTML (and XML or other languages, etc) is
inserted into PHP scripts.

Thanks,
Ash
http://www.ashleysheridan.co.uk




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



RE: [PHP] Re: PHP Header issue

2009-09-18 Thread Bob McConnell
From: Ashley Sheridan
 On Fri, 2009-09-18 at 19:01 +0200, Ralph Deffke wrote:
 sorry man, but no blancs etc. means NOTHING should be send before the
header
 
 it should look like this:
 ?php 
 
 header(Location: advertise2.php); 
 
 ?
 
 here u can do ur html
 
 
 
 not one! single char incl. space should be outputted before the
 header e.g. before the php open tag.
 
 
 I think this sort of issue arises particularly because of the
 misconception that PHP is embedded inside HTML pages. Once a person
has
 that idea in their head, they will start to work with an HTML template
 and add PHP as necessary. While that can work, in cases such as this,
 it's best to remember that HTML (and XML or other languages, etc) is
 inserted into PHP scripts.

After using Perl to generate HTML, that is exactly what it looks like. I
always believed that was the way PHP was designed, so the PHP scripts
are embedded inside the HTML. It is a much more logical construct than
trying to use Perl, or C or ...

Bob McConnell

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



RE: [PHP] Re: PHP Header issue

2009-09-18 Thread Andrea Giammarchi


 I think this sort of issue arises particularly because of the
 misconception that PHP is embedded inside HTML pages. Once a person has
 that idea in their head, they will start to work with an HTML template
 and add PHP as necessary. While that can work, in cases such as this,
 it's best to remember that HTML (and XML or other languages, etc) is
 inserted into PHP scripts.

I think PHP embedded is not a good idea in any case, the output should be the 
last thing ever to manage/perform, and not vice-versa: PHP in the middle of an 
output stream.

This simply means more speed, less implicit or explicit echo/parsing/flow 
interruptions, more control, and more flexibility, since last part ever of the 
required page could decide at the end to produce an html page, an XML, 
eventually transformed via XSL (or transformed via client later), a JSON 
response, a PDF, an csv ... etc etc ... php embedded is the reason php is so 
popular but the reason there are a lot of bad applications as well - not 
because of its embeddable nature, simply 'casue being simple often means being 
used by lots of wannabe programmers sometimes not even interested about 
learning it more than they already know.

I always says PHP is easy to use, but extremely hard to use properly.

The learning curve is often stuck miles before 100/100 ... and I do not 
absolutely consider myself a 100/100 PHP dev ... actually, I do not know 
anybody that cool, maybe because at some point people switch into another 
language a la Python, C#, or Java ...

Just my opinion,
Regards

_
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx

Re: [PHP] header problem

2009-09-10 Thread George Langley
	Hi Blueman. As soon as ANYTHING has been drawn to the browser, you  
cannot use a header command. So you need to work through all of your  
code, and ensure that all of your logic that could result in a header  
call is run BEFORE you send any html code. Is going to be tricky if  
mixing html and php calls.


George


On 10-Sep-09, at 12:27 AM, A.a.k wrote:


hello
I recentrly uploaded my project from localhost to a hosting and  
found many errors and warnings which didnt have in local. one of the  
most annoying one is header('Location xxx').
I have used header to redirect users from pages, and kinda used it  
alot. i know about the whitespace causing warning, but most of the  
pages i'm sending users got html and php mixed so i'm confused about  
how to remove whitespace in a html/php file. the error is :
Warning: Cannot modify header information - headers already sent  
by 

here is a simple example, user update page :
   if($valid)
  {
  $msg='111';
  $user-dbupdate();
   header(Location: /admin/index.php?msg=$msg);

  }
  else
  {
   foreach($errors as $val)
  echo 'p id=error'.$val.'/p';
  }

and on admin index i get $msg and display it.
html
..
//lots of stuff
 ?php
 $msg = $_GET['msg'];
 switch($msg){
 case '111'   echo 'p /p';
  break;
case '421':...
  }
?
//  more html and php

how can i fix this?

--
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 problem

2009-09-10 Thread A.a.k

is there any alternative to header() for redirect users?

George Langley george.lang...@shaw.ca wrote in message 
news:b1b897d4-7448-4b71-bffc-3addc27ce...@shaw.ca...
Hi Blueman. As soon as ANYTHING has been drawn to the browser, you  cannot 
use a header command. So you need to work through all of your  code, and 
ensure that all of your logic that could result in a header  call is run 
BEFORE you send any html code. Is going to be tricky if  mixing html and 
php calls.


George


On 10-Sep-09, at 12:27 AM, A.a.k wrote:


hello
I recentrly uploaded my project from localhost to a hosting and  found 
many errors and warnings which didnt have in local. one of the  most 
annoying one is header('Location xxx').
I have used header to redirect users from pages, and kinda used it  alot. 
i know about the whitespace causing warning, but most of the  pages i'm 
sending users got html and php mixed so i'm confused about  how to remove 
whitespace in a html/php file. the error is :

Warning: Cannot modify header information - headers already sent  by 
here is a simple example, user update page :
   if($valid)
  {
  $msg='111';
  $user-dbupdate();
   header(Location: /admin/index.php?msg=$msg);

  }
  else
  {
   foreach($errors as $val)
  echo 'p id=error'.$val.'/p';
  }

and on admin index i get $msg and display it.
html
..
//lots of stuff
 ?php
 $msg = $_GET['msg'];
 switch($msg){
 case '111'   echo 'p /p';
  break;
case '421':...
  }
?
//  more html and php

how can i fix this?

--
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 problem

2009-09-10 Thread Marcus Gnaß
A.a.k wrote:
 is there any alternative to header() for redirect users?

As far as I know there isn't.

Is the header-error the first error on the page? If not, the other error
message itself is the reason for the header-error and will be solved if
you solve the other error.

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



Re: [PHP] header problem

2009-09-10 Thread Ashley Sheridan
On Thu, 2009-09-10 at 08:57 +0200, A.a.k wrote:
 is there any alternative to header() for redirect users?
 
 George Langley george.lang...@shaw.ca wrote in message 
 news:b1b897d4-7448-4b71-bffc-3addc27ce...@shaw.ca...
  Hi Blueman. As soon as ANYTHING has been drawn to the browser, you  cannot 
  use a header command. So you need to work through all of your  code, and 
  ensure that all of your logic that could result in a header  call is run 
  BEFORE you send any html code. Is going to be tricky if  mixing html and 
  php calls.
 
  George
 
 
  On 10-Sep-09, at 12:27 AM, A.a.k wrote:
 
  hello
  I recentrly uploaded my project from localhost to a hosting and  found 
  many errors and warnings which didnt have in local. one of the  most 
  annoying one is header('Location xxx').
  I have used header to redirect users from pages, and kinda used it  alot. 
  i know about the whitespace causing warning, but most of the  pages i'm 
  sending users got html and php mixed so i'm confused about  how to remove 
  whitespace in a html/php file. the error is :
  Warning: Cannot modify header information - headers already sent  by 
  here is a simple example, user update page :
 if($valid)
{
$msg='111';
$user-dbupdate();
 header(Location: /admin/index.php?msg=$msg);
 
}
else
{
 foreach($errors as $val)
echo 'p id=error'.$val.'/p';
}
 
  and on admin index i get $msg and display it.
  html
  ..
  //lots of stuff
   ?php
   $msg = $_GET['msg'];
   switch($msg){
   case '111'   echo 'p /p';
break;
  case '421':...
}
  ?
  //  more html and php
 
  how can i fix this?
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
  
 
 

Several:

  * Javascript - not always available on your target system, or
blocked by script blocking plugins
  * Meta refresh tags - should be honored by the user agent, but may
not always be.

The problem you have is not that you need to work around this 'problem'
in PHP, but you need to fix your broken code. This problem often comes
up on the list, and is usually because of extra whitespace in include
files, or errors being output to the browser which force the headers to
be sent.

Thanks,
Ash
http://www.ashleysheridan.co.uk




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



Re: [PHP] header problem

2009-09-10 Thread HostWare Kft.
Usually, when I have to redirect the user AFTER headers has been sent (like 
showing an error message), I write this:


SCRIPTlocation=page_to_send.html/SCRIPT

But this will redirect the user at once. If you want the user to read the 
page, you should do something in Javascript with setTimeout(func,timeout) 
function.


BR,
SanTa

- Original Message - 
From: George Langley george.lang...@shaw.ca

To: php-general@lists.php.net
Sent: Thursday, September 10, 2009 8:39 AM
Subject: Re: [PHP] header problem


Hi Blueman. As soon as ANYTHING has been drawn to the browser, you  cannot 
use a header command. So you need to work through all of your  code, and 
ensure that all of your logic that could result in a header  call is run 
BEFORE you send any html code. Is going to be tricky if  mixing html and 
php calls.


George


On 10-Sep-09, at 12:27 AM, A.a.k wrote:


hello
I recentrly uploaded my project from localhost to a hosting and  found 
many errors and warnings which didnt have in local. one of the  most 
annoying one is header('Location xxx').
I have used header to redirect users from pages, and kinda used it  alot. 
i know about the whitespace causing warning, but most of the  pages i'm 
sending users got html and php mixed so i'm confused about  how to remove 
whitespace in a html/php file. the error is :

Warning: Cannot modify header information - headers already sent  by 
here is a simple example, user update page :
   if($valid)
  {
  $msg='111';
  $user-dbupdate();
   header(Location: /admin/index.php?msg=$msg);

  }
  else
  {
   foreach($errors as $val)
  echo 'p id=error'.$val.'/p';
  }

and on admin index i get $msg and display it.
html
..
//lots of stuff
 ?php
 $msg = $_GET['msg'];
 switch($msg){
 case '111'   echo 'p /p';
  break;
case '421':...
  }
?
//  more html and php

how can i fix this?

--
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




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



Re: [PHP] header problem

2009-09-10 Thread Ashley Sheridan
On Thu, 2009-09-10 at 09:04 +0200, Sándor Tamás (HostWare Kft.) wrote:
 Usually, when I have to redirect the user AFTER headers has been sent (like 
 showing an error message), I write this:
 
 SCRIPTlocation=page_to_send.html/SCRIPT
 
 But this will redirect the user at once. If you want the user to read the 
 page, you should do something in Javascript with setTimeout(func,timeout) 
 function.
 
 BR,
 SanTa
 
 - Original Message - 
 From: George Langley george.lang...@shaw.ca
 To: php-general@lists.php.net
 Sent: Thursday, September 10, 2009 8:39 AM
 Subject: Re: [PHP] header problem
 
 
  Hi Blueman. As soon as ANYTHING has been drawn to the browser, you  cannot 
  use a header command. So you need to work through all of your  code, and 
  ensure that all of your logic that could result in a header  call is run 
  BEFORE you send any html code. Is going to be tricky if  mixing html and 
  php calls.
 
  George
 
 
  On 10-Sep-09, at 12:27 AM, A.a.k wrote:
 
  hello
  I recentrly uploaded my project from localhost to a hosting and  found 
  many errors and warnings which didnt have in local. one of the  most 
  annoying one is header('Location xxx').
  I have used header to redirect users from pages, and kinda used it  alot. 
  i know about the whitespace causing warning, but most of the  pages i'm 
  sending users got html and php mixed so i'm confused about  how to remove 
  whitespace in a html/php file. the error is :
  Warning: Cannot modify header information - headers already sent  by 
  here is a simple example, user update page :
 if($valid)
{
$msg='111';
$user-dbupdate();
 header(Location: /admin/index.php?msg=$msg);
 
}
else
{
 foreach($errors as $val)
echo 'p id=error'.$val.'/p';
}
 
  and on admin index i get $msg and display it.
  html
  ..
  //lots of stuff
   ?php
   $msg = $_GET['msg'];
   switch($msg){
   case '111'   echo 'p /p';
break;
  case '421':...
}
  ?
  //  more html and php
 
  how can i fix this?
 
  -- 
  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
  
 
 
Don't use a timer to redirect if you want the user to read a message, as
this assumes that the visitor is a good reader. This is forgetting all
of those visitors with reading difficulties (i.e. Dyslexia), those users
who have attention problems who can't focus on text for long periods
(i.e. ADHD) and any users who rely on things such as screen readers
(which are slower than reading text yourself (if you're an average
reader!) ) or a Braille browser.

In cases such as these, it's best to let the visitor move at their own
pace and not redirect until they want to.

Thanks,
Ash
http://www.ashleysheridan.co.uk




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



RE: [PHP] header problem

2009-09-10 Thread Arno Kuhl
-Original Message-
From: A.a.k [mailto:blue...@gmail.com] 
Sent: 10 September 2009 08:27 AM
To: php-general@lists.php.net
Subject: [PHP] header problem

hello
I recentrly uploaded my project from localhost to a hosting and found many
errors and warnings which didnt have in local. one of the most annoying one
is header('Location xxx').
I have used header to redirect users from pages, and kinda used it alot. i
know about the whitespace causing warning, but most of the pages i'm sending
users got html and php mixed so i'm confused about how to remove whitespace
in a html/php file. the error is :
Warning: Cannot modify header information - headers already sent by 
here is a simple example, user update page :
 if($valid)
{
$msg='111';
$user-dbupdate();
 header(Location: /admin/index.php?msg=$msg);

}
else
{
 foreach($errors as $val)
echo 'p id=error'.$val.'/p';
}

and on admin index i get $msg and display it.
html
..
//lots of stuff
   ?php
   $msg = $_GET['msg'];
   switch($msg){
   case '111'   echo 'p /p';
break;
  case '421':...
}
?
//  more html and php

how can i fix this? 
--

It's possible that on your localhost you have output_buffering set on either
in php.ini or in a .htaccess, which would avoid the displayed error about
headers. If it's switched on locally and off for your host server then
you'll get the problem you reported. Check that this is off locally (use
phpinfo) so that you can be sure your code is working properly before you
upload.

Alternatively if you want to be able to do a redirect after you've already
started your output (this is sometimes done for error handling) you could
use ob_start() to start output buffering, ob_end_clean() to clear the output
buffer and start again, and ob_flush() to send the output buffer. If you
want to continue using output buffering after an ob_end_clean() you'll have
to do an ob_start() again.

Cheers
Arno


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



RE: [PHP] header() and passing sessions

2009-04-15 Thread abdulazeez alugo


 

 Date: Wed, 15 Apr 2009 11:09:19 -0500
 From: awill...@mdah.state.ms.us
 To: php-general@lists.php.net
 Subject: [PHP] header() and passing sessions
 
 I need some help passing a session variable with a header() function. 
 According to www.php.net/header, the documentation states:
 
 *Note*: Session ID is not passed with Location header even if 
 session.use_trans_sid 
 session.configuration.php#ini.session.use-trans-sid is enabled. It 
 must by passed manually using *SID* constant.
 
 so, I'm trying to manually pass the SID, but not having any luck. Here 
 is a snippet of my code:
 
 There is a file login.php which has session_start(); and sets 
 $_SESSION[username] with the username you logged in with from 
 index.php and has a form to click View Pending Requests which has the 
 action of option.php.
 
 -- option.php --
 ?php
 session_start();
 if ($_POST[option] == View Pending Requests)
 {
 header('Location: 
 http://intra.mdah.state.ms.us/helpdesk/viewpending.php?PHPSESSID='.session_id());
 }
 ?
 
 --viewpending.php --
 ?php
 session_start();
 if (!$_SESSION[username])
 {
 echo You have not logged in;
 exit;
 }
 ?
 
 so you click on View Pending Requests, and the URL in your browser is:
 
 http://intra.mdah.state.ms.us/helpdesk/viewpending.php?PHPSESSID=du75p41hel9k1vpuah799l2ce7
 
 but viewpending.php says You have not logged in. Why is that?

 

Hi,

Well I'ld say the reason is quite obvious. You have simply not set 
$_session[username] . I'ld have done something like:

 

-- option.php --
?php
 session_start();
 if ($_POST[option] == View Pending Requests)
{

$_session[username]= true;  //sets the session
 header('Location: 
 http://intra.mdah.state.ms.us/helpdesk/viewpending.php?PHPSESSID='.SID);// 
I'ld use SID
 } 
 ?


 

--viewpending.php -
 ?php
 session_start();
 if ($_SESSION[username] !=true)
 {
 echo You have not logged in;
 exit;
 }
 ?

 

I hope this helps. try it.

Cheers

Alugo Abdulazeez



_
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx

Re: [PHP] header() and passing sessions

2009-04-15 Thread Adam Williams

abdulazeez alugo wrote:


Hi,
Well I'ld say the reason is quite obvious. You have simply not set 
$_session[username] . I'ld have done something like:
 
-- option.php --

?php
 session_start();
 if ($_POST[option] == View Pending Requests)
{
$_session[username]= true;  //sets the session
 header('Location: 
http://intra.mdah.state.ms.us/helpdesk/viewpending.php?PHPSESSID='.SID);
// 
http://intra.mdah.state.ms.us/helpdesk/viewpending.php?PHPSESSID=%27.SID%29;%A0%A0%A0+// 
I'ld use SID

 }
 ?

 
--viewpending.php -

 ?php
 session_start();
 if ($_SESSION[username] !=true)
 {
 echo You have not logged in;
 exit;
 }
 ?
 
I hope this helps. try it.

Cheers
Alugo Abdulazeez




Well the thing is, $_SESSION[username] is set.  If I change option.php to:

?php
session_start();
echo session username is .$_SESSION[username];
/*if ($_POST[option] == View Pending Requests)
   {
   header('Location: 
http://intra.mdah.state.ms.us/helpdesk/viewpending.php?PHPSESSID='.session_id());

   }
*/
?

and click on View Pending Requests, it prints:

session username is awilliam




Re: [PHP] Header - Redirect Command Not Working

2009-03-13 Thread Jan G.B.
2009/3/11 Daniel Brown danbr...@php.net:
 On Wed, Mar 11, 2009 at 12:38, Jan G.B. ro0ot.w...@googlemail.com wrote:
 wrong:
 Location: file.txt
 and this is correct
 Location: http://www.x.x/file.txt;

 Not all clients behave like yours and accept the wrong header.

    The *protocol* does not, but the HTTP/1.1 specification does.
 However, it should be noted that *all* modern browsers accept relative
 URI's vs. the requirement of absolute URI's.  Thus, the header is
 non-standard, but is not wrong.  Your point is accurate, though:
 it should include the full resource.

 erm  META should be in a html document inside the HEAD, not 
 *anywhere*.

    That's the recommended order, but it's not required.  Not even in
 1982 when the spec was written.  In fact, the placement in HEAD is so
 that, with the original specifications, a server would be permitted
 (though again, not required) to read the META tags within HEAD to form
 and send its own headers via HTTP in conjunction with the plain-text
 data from the document.

 Very, very, very bad idea. You just opened a cross site scripting bug.

 Imagine someone opens this URL
 host/yourfile?id=scriptalert(document.cookie)/script

 You must always escape any input you take.
 see http://php.net/security

    This is always true of any user-side input being sent to a script
 (though the example may seem a little humorous because, if a person is
 that desperate to see their cookie data, their browser truly sucks).

    Once again, for anyone who hasn't been paying attention or who
 doesn't yet have the acquired knowledge from their own painful
 experiences, *never* copy and paste code from this list or any other
 medium.  Always evaluate it yourself first.  This list is meant for
 assistance and those on it provide pseudocode, not production-worthy
 code.  The rest is, as has always been, at your own risk.


Where's your point? Proving that you know the well known clients and
their behaviour?
Just stick to the standards. easy. no or less errors occur.

Also, it's quite clear to any thinking person, that alerting the
cookie is an example that shows how easy an attacker can catch the
session id. it's a well known common example.
it's more humorous that your choice is to ignore or fight RFCs, open
standards and that you don't even know the most common XSS example -
but that is just my opninion. :-)

have a nice day.

 /Daniel P. Brown
 50% Off All Shared Hosting Plans at PilotPig: Use Coupon x

stop spamming me, thanks. :-)

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



Re: [PHP] Header - Redirect Command Not Working

2009-03-13 Thread Daniel Brown
On Fri, Mar 13, 2009 at 13:15, Jan G.B. ro0ot.w...@googlemail.com wrote:

 Where's your point? Proving that you know the well known clients and
 their behaviour?
 Just stick to the standards. easy. no or less errors occur.

Okay, I'm not going to get into a flame war with you, because it's
obvious that your native language isn't English, and you may not
understand that what I'm saying is not in contradiction to you, but
rather explaining points you've made.

 Also, it's quite clear to any thinking person, that alerting the
 cookie is an example that shows how easy an attacker can catch the
 session id. it's a well known common example.
 it's more humorous that your choice is to ignore or fight RFCs, open
 standards and that you don't even know the most common XSS example -
 but that is just my opninion. :-)

What's humorous to me is that you came out of nowhere and have no
understanding or respect for plain logic in mailing list
communication.  I never chose to ignore or fight RFCs, Jan --- I'm
the one who alluded to them in the first place (the spec) comments.
After you've had a few more years at the command of your keyboard and
develop a more thorough understanding of communication and technical
documents instead of the hacker mindset - a term I use very loosely
here - then I'd welcome discussion on your points.  Because while some
are valid, the presentation plainly needs work.

Oh, and what you presented as your opninion wasn't even close to
being accurate.  You should instead have said it's what you assumed,
for many obvious reasons.  Take that as poignantly as I am inferring
it.

 have a nice day.

 /Daniel P. Brown
 50% Off All Shared Hosting Plans at PilotPig: Use Coupon x

 stop spamming me, thanks. :-)

Learn the definition of spamming before you join a mailing list,
thanks.  ;-P

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] Header - Redirect Command Not Working

2009-03-11 Thread Jan G.B.
Hi Dave (?)

2009/3/11 revDAVE c...@hosting4days.com:
 Hi Bastien - Stuart  Daniel

 Thanks for your help!


 On 3/10/2009 12:16 PM, Bastien Koert phps...@gmail.com wrote:

 Are you getting an error? What does 'not working' mean?

 No errors the page just stayed on the
 header('Location: show.php'); page - never went to: show.php


One more thing to mention: The HTTP Protocoll requires you to give a
full URL on Location Headers. That means that this is wrong:
Location: file.txt
and this is correct
Location: http://www.x.x/file.txt;

Not all clients behave like yours and accept the wrong header.




 Q: I might have learned something Does the: header('Location: xxx.php');
 command need to be in the first php block? On some pages when I make multi
 php blocks into 1 big one and put the header command inside it - it seems to
 work better - is this true?

All HTTP headers must be send before your script generates *any* output.
Output means echo's, PHP Notices, etc.
If you *must* output stuff before sending an header, you can use
output buffering, see http://php.net/ob_start


 Q: Also, is it possible that extra whitespace inside the php block can cause
 the header command to not work? (I might have that happening also - looking
 into it)


Yes, *any* output - no matter if you output   or x or even :-).




     Well, if the above is in fact the case (and yes, different
 versions and installations have been known to respond differently),
 then you can use a browser-based meta refresh, which will work for all
 browsers anyway:


unless disabled by the user.


 ?php
 //  your code
 header('Location: show.php');
 echo 'meta http-equiv=refresh content=0;show.php';


erm  META should be in a html document inside the HEAD, not *anywhere*.



 I tried refresh Daniel - and it worked great!

 I even added a GET var to it - worked also

 echo 'meta http-equiv=refresh content=0;show.php?id='.$_GET[id].'';


Very, very, very bad idea. You just opened a cross site scripting bug.

Imagine someone opens this URL
host/yourfile?id=scriptalert(document.cookie)/script

You must always escape any input you take.
see http://php.net/security



 Thanks again folks!



You're welcome.

Byebye

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



Re: [PHP] Header - Redirect Command Not Working

2009-03-11 Thread Daniel Brown
On Wed, Mar 11, 2009 at 12:38, Jan G.B. ro0ot.w...@googlemail.com wrote:

 One more thing to mention: The HTTP Protocoll requires you to give a
 full URL on Location Headers. That means that this is wrong:
 Location: file.txt
 and this is correct
 Location: http://www.x.x/file.txt;

 Not all clients behave like yours and accept the wrong header.

The *protocol* does not, but the HTTP/1.1 specification does.
However, it should be noted that *all* modern browsers accept relative
URI's vs. the requirement of absolute URI's.  Thus, the header is
non-standard, but is not wrong.  Your point is accurate, though:
it should include the full resource.

 erm  META should be in a html document inside the HEAD, not 
 *anywhere*.

That's the recommended order, but it's not required.  Not even in
1982 when the spec was written.  In fact, the placement in HEAD is so
that, with the original specifications, a server would be permitted
(though again, not required) to read the META tags within HEAD to form
and send its own headers via HTTP in conjunction with the plain-text
data from the document.

 Very, very, very bad idea. You just opened a cross site scripting bug.

 Imagine someone opens this URL
 host/yourfile?id=scriptalert(document.cookie)/script

 You must always escape any input you take.
 see http://php.net/security

This is always true of any user-side input being sent to a script
(though the example may seem a little humorous because, if a person is
that desperate to see their cookie data, their browser truly sucks).

Once again, for anyone who hasn't been paying attention or who
doesn't yet have the acquired knowledge from their own painful
experiences, *never* copy and paste code from this list or any other
medium.  Always evaluate it yourself first.  This list is meant for
assistance and those on it provide pseudocode, not production-worthy
code.  The rest is, as has always been, at your own risk.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] Header - Redirect Command Not Working

2009-03-11 Thread Shawn McKenzie
Daniel Brown wrote:
 On Wed, Mar 11, 2009 at 12:38, Jan G.B. ro0ot.w...@googlemail.com wrote:
 One more thing to mention: The HTTP Protocoll requires you to give a
 full URL on Location Headers. That means that this is wrong:
 Location: file.txt
 and this is correct
 Location: http://www.x.x/file.txt;

 Not all clients behave like yours and accept the wrong header.
 
 The *protocol* does not, but the HTTP/1.1 specification does.
 However, it should be noted that *all* modern browsers accept relative
 URI's vs. the requirement of absolute URI's.  Thus, the header is
 non-standard, but is not wrong.  Your point is accurate, though:
 it should include the full resource.
 
 erm  META should be in a html document inside the HEAD, not 
 *anywhere*.
 
 That's the recommended order, but it's not required.  Not even in
 1982 when the spec was written.  In fact, the placement in HEAD is so
 that, with the original specifications, a server would be permitted
 (though again, not required) to read the META tags within HEAD to form
 and send its own headers via HTTP in conjunction with the plain-text
 data from the document.

Though the w3c HTML/XHTML standards do show the META tag inside the
head, hence the validation errors
(http://validator.w3.org/#validate_by_input):

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
head
titlepage/title
/head
meta name=revision content=1 /
body
/body
/html

Line 7, Column 35: document type does not allow element meta here.
meta name=revision content=1 /

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
html lang=eng
head
titlepage/title
/head
meta name=revision content=1
body
/body
/html

Line 6, Column 33: document type does not allow element META here.
meta name=revision content=1


-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Header - Redirect Command Not Working

2009-03-11 Thread Daniel Brown
On Wed, Mar 11, 2009 at 14:12, Shawn McKenzie nos...@mckenzies.net wrote:

 Though the w3c HTML/XHTML standards do show the META tag inside the
 head, hence the validation errors
 (http://validator.w3.org/#validate_by_input):

Right, which should be no surprise.  Validation follows the
recommended guidelines (unlike 90% of the spaghetti-coded websites
with which I'm sure we all deal on a daily basis).

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] Header - Redirect Command Not Working

2009-03-10 Thread Bastien Koert
On Tue, Mar 10, 2009 at 3:13 PM, revDAVE c...@hosting4days.com wrote:

 Newbie question...

 At the end of a php block I'm trying to use a redirect to go to another
 page.

 header('Location: show.php');

 It works on my test server w php 5.2.6 but not at the main server w v 5.12

 Is there a way to get it to go to the other page (even with a different
 command/function) - or am I doing something wrong?



 --
 Thanks - RevDave
 Cool @ hosting4days . com
 [db-lists 09]




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


Are you getting an error? What does 'not working' mean?

-- 

Bastien

Cat, the other other white meat


Re: [PHP] Header - Redirect Command Not Working

2009-03-10 Thread Stuart
2009/3/10 revDAVE c...@hosting4days.com

 Newbie question...

 At the end of a php block I'm trying to use a redirect to go to another
 page.

 header('Location: show.php');

 It works on my test server w php 5.2.6 but not at the main server w v 5.12

 Is there a way to get it to go to the other page (even with a different
 command/function) - or am I doing something wrong?


Is display_errors on and error_reporting set to at least E_ALL? My guess
would be your test server has output buffering on but your main server does
not. Without errors there's no way to be sure.

-Stuart

-- 
http://stut.net/


Re: [PHP] Header - Redirect Command Not Working

2009-03-10 Thread Daniel Brown
On Tue, Mar 10, 2009 at 15:13, revDAVE c...@hosting4days.com wrote:
 Newbie question...

 At the end of a php block I'm trying to use a redirect to go to another
 page.

 header('Location: show.php');

 It works on my test server w php 5.2.6 but not at the main server w v 5.12

Did you already have some output sent to the browser?  That may be
causing header() not to be able to send the Location header to the
browser properly.

 Is there a way to get it to go to the other page (even with a different
 command/function) - or am I doing something wrong?

Well, if the above is in fact the case (and yes, different
versions and installations have been known to respond differently),
then you can use a browser-based meta refresh, which will work for all
browsers anyway:

?php
//  your code
header('Location: show.php');
echo 'meta http-equiv=refresh content=0;show.php';
flush();
exit(0);
?

This kills three birds with the same stone like so:

1.) It tries to use the header() location redirect.
2.) It falls back on browser-based redirection.
3.) It forces a flush() of the data to the client, regardless
of minimum size limits.
4.) It forces the script to exit with a non-error code of 0.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] Header - Redirect Command Not Working

2009-03-10 Thread revDAVE
Hi Bastien - Stuart  Daniel

Thanks for your help!


On 3/10/2009 12:16 PM, Bastien Koert phps...@gmail.com wrote:

 Are you getting an error? What does 'not working' mean?

No errors the page just stayed on the
header('Location: show.php'); page - never went to: show.php

---

On 3/10/2009 12:17 PM, Stuart stut...@gmail.com wrote:

 Is display_errors on and error_reporting set to at least E_ALL? My guess
 would be your test server has output buffering on but your main server does
 not. Without errors there's no way to be sure.

Not sure Stuart - I will look into this




On 3/10/2009 12:21 PM, Daniel Brown danbr...@php.net wrote:

 It works on my test server w php 5.2.6 but not at the main server w v 5.12
 
 Did you already have some output sent to the browser?  That may be
 causing header() not to be able to send the Location header to the
 browser properly.

Yes the page if a combo form / action page

Q: I might have learned something Does the: header('Location: xxx.php');
command need to be in the first php block? On some pages when I make multi
php blocks into 1 big one and put the header command inside it - it seems to
work better - is this true?

Q: Also, is it possible that extra whitespace inside the php block can cause
the header command to not work? (I might have that happening also - looking
into it) 


 
 Is there a way to get it to go to the other page (even with a different
 command/function) - or am I doing something wrong?
 
 Well, if the above is in fact the case (and yes, different
 versions and installations have been known to respond differently),
 then you can use a browser-based meta refresh, which will work for all
 browsers anyway:
 
 ?php
 //  your code
 header('Location: show.php');
 echo 'meta http-equiv=refresh content=0;show.php';
 flush();
 exit(0);
 ?


I tried refresh Daniel - and it worked great!

I even added a GET var to it - worked also

echo 'meta http-equiv=refresh content=0;show.php?id='.$_GET[id].'';

Thanks again folks!


 
 This kills three birds with the same stone like so:
 
 1.) It tries to use the header() location redirect.
 2.) It falls back on browser-based redirection.
 3.) It forces a flush() of the data to the client, regardless
 of minimum size limits.
 4.) It forces the script to exit with a non-error code of 0.





--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]




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



Re: [PHP] header(Location: ) wont show up in logs of either server

2009-01-08 Thread Jim Lucas
Rene Veerman wrote:
 Hi, i'm doing a forward to another server (somehost.com/2.php) by using
 
 header(Location: http://someserver.com/script/1.php;);
 
 But on neither servers do i get hits in the apache access log for either
 script being called.
 
 Any ideas?
 
 

Make sure you are looking at the right log file.

-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] header(Location: ) wont show up in logs of either server

2009-01-08 Thread Andrew Ballard
On Thu, Jan 8, 2009 at 7:17 PM, Rene Veerman rene7...@gmail.com wrote:
 Hi, i'm doing a forward to another server (somehost.com/2.php) by using

 header(Location: http://someserver.com/script/1.php;);

 But on neither servers do i get hits in the apache access log for either
 script being called.

 Any ideas?



I'll take the simple answer and say neither script IS being called?
OK, I'll go back to my corner now.

Andrew

[Geesh - I take the time to send out a sarcastic message and forget to
send it to the list.]

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



Re: [PHP] header(Location: ) wont show up in logs of either server

2009-01-08 Thread Rene Veerman

Andrew Ballard wrote:

I'll take the simple answer and say neither script IS being called?
OK, I'll go back to my corner now.

Andrew

[Geesh - I take the time to send out a sarcastic message and forget to
send it to the list.]
  


The scripts are called, because i can see the data coming back from 
someserver.com



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



Re: [PHP] header(Location: ) wont show up in logs of either server

2009-01-08 Thread Jim Lucas

Rene Veerman wrote:

Andrew Ballard wrote:

I'll take the simple answer and say neither script IS being called?
OK, I'll go back to my corner now.

Andrew

[Geesh - I take the time to send out a sarcastic message and forget to
send it to the list.]
  


The scripts are called, because i can see the data coming back from 
someserver.com





Again, make sure you are checking the right log file.

--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] header modify errors

2008-12-15 Thread Jim Lucas
Terion Miller wrote:
 I am working from home today and getting this error with my copy of my
 project:
 *Warning*: Cannot modify header information - headers already sent by
 (output started at C:\Inetpub\Xampp\htdocs\SNLeader\WOSystem\Welcome.php:31)
 in *C:\Inetpub\Xampp\htdocs\SNLeader\WOSystem\inc\dbconn_openTest.php* on
 line *3*
 
 *Warning*: Cannot modify header information - headers already sent by
 (output started at C:\Inetpub\Xampp\htdocs\SNLeader\WOSystem\Welcome.php:31)
 in *C:\Inetpub\Xampp\htdocs\SNLeader\WOSystem\inc\dbconn_openTest.php* on
 line *4*
 Could not connect to the database.
 
 I have set my php.ini file output_buffering to ON it was off (read in a past
 post that will fix this error--but it did not)
 I also set session.cache_limiter =  to nothing it was set to nocache
 
 Any other things I'm missing?
 Thanks
 Terion
 

Make sure you have no .htaccess or VirtualHost ... blocks that are overriding 
your php.ini settings.

Plus, make sure you restart to make the changes take effect.

-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Header() - POST

2008-09-11 Thread Luke
But surely you can post data with Javascript? Ach, at college now I can't
access my source, I forget how to do it exactly...

2008/9/11 mike [EMAIL PROTECTED]

 On Wed, Sep 10, 2008 at 3:42 PM, tedd [EMAIL PROTECTED] wrote:

  Then use cURL as was suggested before.

 the reply was on his original attempt to header(POST: /foo) ... that was
 it.

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




-- 
Luke Slater


Re: [PHP] Header() - POST

2008-09-11 Thread mike
On Thu, Sep 11, 2008 at 12:47 AM, Luke [EMAIL PROTECTED] wrote:
 But surely you can post data with Javascript? Ach, at college now I can't
 access my source, I forget how to do it exactly...

yes, i said javascript. something on the client side has to do it.
(well besides for a curl-based form post inside of php, but something
is telling the php script to do that to begin with)

header() in PHP is a command for the server to send a header to the
client. POST is an HTTP request verb...

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



Re: [PHP] Header() - POST

2008-09-11 Thread Dan Joseph
I actually just completely re-engineered this page.  It made sense reading
what everyone had to say.  The extra page that I wanted to post to was
really not needed.  I have everything just contained in the one php script
now, and its working perfectly that way.  After it submits the order, it
then redirects to a confirmation page, rather than trying to validate,
rebuilt the post string, and then submitting that to another page for
processing and confirmation.  Just made more sense really.

In the future, though, if I find I need to do this, curl seemed to be the
best option.  I've used javascript in the past to do it, but it seemed
messy to me.

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life.


Re: [PHP] Header() - POST

2008-09-10 Thread tedd

At 10:14 AM -0700 9/5/08, mike wrote:

if you want to re-post data you need to look at a client-side
alternative using javascript (or applets - flash, java, etc)


OR just use hidden input.

I do that with forms that gather pages of data. You keep submitting 
the same page over and over gathering the different sets of the data 
you need and then forwarding the data you gathered from previous 
pages via a hidden input OR a SESSION.


I have even used a recursive include to keep the process going until 
you have everything you need.


Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Header() - POST

2008-09-10 Thread mike
On Wed, Sep 10, 2008 at 2:51 PM, tedd [EMAIL PROTECTED] wrote:
 At 10:14 AM -0700 9/5/08, mike wrote:

 if you want to re-post data you need to look at a client-side
 alternative using javascript (or applets - flash, java, etc)

 OR just use hidden input.

 I do that with forms that gather pages of data. You keep submitting the same
 page over and over gathering the different sets of the data you need and
 then forwarding the data you gathered from previous pages via a hidden input
 OR a SESSION.

can't re-post data without something triggering it... that was what i
was saying.

in your case, the user is hitting submit again, or javascript is
triggering the submit on a form completion. but you can't just POST
data without something forcing it.

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



Re: [PHP] Header() - POST

2008-09-10 Thread tedd

At 3:32 PM -0700 9/10/08, mike wrote:

On Wed, Sep 10, 2008 at 2:51 PM, tedd [EMAIL PROTECTED] wrote:

 At 10:14 AM -0700 9/5/08, mike wrote:


 if you want to re-post data you need to look at a client-side
 alternative using javascript (or applets - flash, java, etc)


 OR just use hidden input.

 I do that with forms that gather pages of data. You keep submitting the same
 page over and over gathering the different sets of the data you need and
 then forwarding the data you gathered from previous pages via a hidden input
 OR a SESSION.


can't re-post data without something triggering it... that was what i
was saying.

in your case, the user is hitting submit again, or javascript is
triggering the submit on a form completion. but you can't just POST
data without something forcing it.


Then use cURL as was suggested before.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Header() - POST

2008-09-10 Thread mike
On Wed, Sep 10, 2008 at 3:42 PM, tedd [EMAIL PROTECTED] wrote:

 Then use cURL as was suggested before.

the reply was on his original attempt to header(POST: /foo) ... that was it.

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



Re: [PHP] Header() - POST

2008-09-05 Thread Wolf
!-- SNIP --
 scrubbing them, and rebuidling the post string and trying to resubmitt it
 using headers().  I'm getting this error:

Why do you want to re-submit it?

Why not just parse it in the same page?

If not that, then use sessions and set the information, do a meta-refresh to 
redirect to the processing page, then use the processing page to pull the 
session information and make sure it came from the correct page.

HTH,
Wolf

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



Re: [PHP] Header() - POST

2008-09-05 Thread Dan Joseph
On Fri, Sep 5, 2008 at 11:48 AM, Wolf [EMAIL PROTECTED] wrote:

 !-- SNIP --
  scrubbing them, and rebuidling the post string and trying to resubmitt it
  using headers().  I'm getting this error:

 Why do you want to re-submit it?

 Why not just parse it in the same page?

 If not that, then use sessions and set the information, do a meta-refresh
 to redirect to the processing page, then use the processing page to pull the
 session information and make sure it came from the correct page.

 HTH,
 Wolf


Hmm good question on why I am re-submitting to a new page.  Honestly, I have
no good answer for that other than I have been rushing this part of the
system for two days to get it done.

I didn't think of Sessions, that's actually not a bad idea at all.  I am
going to re-think the re-submitting thing, and if I stick with it, I'll give
our session idea a shot.

Thanks for the idea!

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life.


RE: [PHP] Header() - POST

2008-09-05 Thread Boyd, Todd M.
 -Original Message-
 From: Dan Joseph [mailto:[EMAIL PROTECTED]
 Sent: Friday, September 05, 2008 10:59 AM
 To: PHP General
 Subject: Re: [PHP] Header() - POST
 
 On Fri, Sep 5, 2008 at 11:48 AM, Wolf [EMAIL PROTECTED] wrote:
 
  !-- SNIP --
   scrubbing them, and rebuidling the post string and trying to
 resubmitt it
   using headers().  I'm getting this error:
 
  Why do you want to re-submit it?
 
  Why not just parse it in the same page?
 
  If not that, then use sessions and set the information, do a meta-
 refresh
  to redirect to the processing page, then use the processing page to
 pull the
  session information and make sure it came from the correct page.
 
  HTH,
  Wolf
 
 
 Hmm good question on why I am re-submitting to a new page.  Honestly,
I
 have
 no good answer for that other than I have been rushing this part of
the
 system for two days to get it done.
 
 I didn't think of Sessions, that's actually not a bad idea at all.  I
 am
 going to re-think the re-submitting thing, and if I stick with it,
I'll
 give
 our session idea a shot.

I think what Wolf was getting at is... if the data you're scrubbing is
being re-submitted to the same page, why re-submit it at all? Why not
just scrub it and then do whatever it is you want to do with it instead
of putting an extra step in-between?

I see your model like this:
1.) Get POST data
2.) Scrub POST data
3.) Re-submit POST data
4.) Deal with POST data

Whereas I'm getting at this:
1.) Get POST data
2.) Scrub POST data
3.) Deal with POST data


Todd Boyd
Web Programmer




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



Re: [PHP] Header() - POST

2008-09-05 Thread Stut

On 5 Sep 2008, at 16:43, Dan Joseph wrote:
I am trying to figure out how to build a post string, and then user  
header

to post it.  I've done some research and I am not getting very far.

Basically what I'm doing is taking POST items, then validating them,
scrubbing them, and rebuidling the post string and trying to  
resubmitt it

using headers().  I'm getting this error:
ErrorCGI ErrorThe specified CGI application misbehaved by not  
returning a

complete set of HTTP headers.

Here is my header code, and the post string below it.  I don't have  
any idea

what I'm missing or doing wrong.  Any help is appreciated!

header( POST /v2/order_submitorder.php HTTP/1.0 );
header( Host: new.vtusa.com );
header( Content-Type: application/x-www-form-urlencoded );
header( Content-Length:  . strlen( $post_string ) );
header( $post_string );


You're trying to post to the browser which won't know how to handle  
it. The header() function is modifying the response headers that are  
being sent back to the browser, they do not create a new request.


If you want to do a new request I suggest looking at curl. If you  
actually want the browser to make the new request the only way is to  
return a hidden form and auto-submit it with JS. However, as someone  
else pointed out if that second request is coming back to the same  
server there probably isn't any need for a second request at all.


-Stut

--
http://stut.net/

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



Re: [PHP] Header() - POST

2008-09-05 Thread Dan Joseph
On Fri, Sep 5, 2008 at 12:11 PM, Boyd, Todd M. [EMAIL PROTECTED] wrote:

  -Original Message-
  From: Dan Joseph [mailto:[EMAIL PROTECTED]
  Sent: Friday, September 05, 2008 10:59 AM
  To: PHP General
  Subject: Re: [PHP] Header() - POST
 
  On Fri, Sep 5, 2008 at 11:48 AM, Wolf [EMAIL PROTECTED] wrote:
 
   !-- SNIP --
scrubbing them, and rebuidling the post string and trying to
  resubmitt it
using headers().  I'm getting this error:
  
   Why do you want to re-submit it?
  
   Why not just parse it in the same page?
  
   If not that, then use sessions and set the information, do a meta-
  refresh
   to redirect to the processing page, then use the processing page to
  pull the
   session information and make sure it came from the correct page.
  
   HTH,
   Wolf
  
 
  Hmm good question on why I am re-submitting to a new page.  Honestly,
 I
  have
  no good answer for that other than I have been rushing this part of
 the
  system for two days to get it done.
 
  I didn't think of Sessions, that's actually not a bad idea at all.  I
  am
  going to re-think the re-submitting thing, and if I stick with it,
 I'll
  give
  our session idea a shot.

 I think what Wolf was getting at is... if the data you're scrubbing is
 being re-submitted to the same page, why re-submit it at all? Why not
 just scrub it and then do whatever it is you want to do with it instead
 of putting an extra step in-between?

 I see your model like this:
 1.) Get POST data
 2.) Scrub POST data
 3.) Re-submit POST data
 4.) Deal with POST data

 Whereas I'm getting at this:
 1.) Get POST data
 2.) Scrub POST data
 3.) Deal with POST data


 Todd Boyd
 Web Programmer




I'm actually not posting back to the same page, I was posting to a different
one.  Which still, when he mentioned it, it didn't make sense why I am doing
that.  I am in agreement with you and Wolf.  I should just scrub it and deal
with it, not re-submit it off to another place.

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life.


RE: [PHP] Header() - POST

2008-09-05 Thread Boyd, Todd M.
 -Original Message-
 From: Dan Joseph [mailto:[EMAIL PROTECTED]
 Sent: Friday, September 05, 2008 11:16 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] Header() - POST
 
 On Fri, Sep 5, 2008 at 12:11 PM, Boyd, Todd M. [EMAIL PROTECTED]
 wrote:
 
   -Original Message-
   From: Dan Joseph [mailto:[EMAIL PROTECTED]
   Sent: Friday, September 05, 2008 10:59 AM
   To: PHP General
   Subject: Re: [PHP] Header() - POST
  
   On Fri, Sep 5, 2008 at 11:48 AM, Wolf [EMAIL PROTECTED] wrote:
  
!-- SNIP --
 scrubbing them, and rebuidling the post string and trying to
   resubmitt it
 using headers().  I'm getting this error:
   
Why do you want to re-submit it?
   
Why not just parse it in the same page?
   
If not that, then use sessions and set the information, do a
 meta-
   refresh
to redirect to the processing page, then use the processing page
 to
   pull the
session information and make sure it came from the correct page.
   
HTH,
Wolf
   
  
   Hmm good question on why I am re-submitting to a new page.
 Honestly,
  I
   have
   no good answer for that other than I have been rushing this part
of
  the
   system for two days to get it done.
  
   I didn't think of Sessions, that's actually not a bad idea at all.
 I
   am
   going to re-think the re-submitting thing, and if I stick with it,
  I'll
   give
   our session idea a shot.
 
  I think what Wolf was getting at is... if the data you're scrubbing
 is
  being re-submitted to the same page, why re-submit it at all? Why
not
  just scrub it and then do whatever it is you want to do with it
 instead
  of putting an extra step in-between?
 
  I see your model like this:
  1.) Get POST data
  2.) Scrub POST data
  3.) Re-submit POST data
  4.) Deal with POST data
 
  Whereas I'm getting at this:
  1.) Get POST data
  2.) Scrub POST data
  3.) Deal with POST data
 
 
  Todd Boyd
  Web Programmer
 
 
 
 
 I'm actually not posting back to the same page, I was posting to a
 different
 one.  Which still, when he mentioned it, it didn't make sense why I am
 doing
 that.  I am in agreement with you and Wolf.  I should just scrub it
and
 deal
 with it, not re-submit it off to another place.

On a side note... in the future, if you find that a particular process
calls for POSTing to a different page, the cURL library (which I believe
is now included with PHP by default in v5.x+) can accomplish a plethora
of wonderful stuff that would ordinarily be handled by a browser
(POSTing, basic HTTP authentication, SSL certs, etc.).


Todd Boyd
Web Programmer




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



Re: [PHP] Header() - POST

2008-09-05 Thread mike
On Fri, Sep 5, 2008 at 9:20 AM, Boyd, Todd M. [EMAIL PROTECTED] wrote:

 On a side note... in the future, if you find that a particular process
 calls for POSTing to a different page, the cURL library (which I believe
 is now included with PHP by default in v5.x+) can accomplish a plethora
 of wonderful stuff that would ordinarily be handled by a browser
 (POSTing, basic HTTP authentication, SSL certs, etc.).

correct: curl is king for that

OP: sending POST to the browser doesn't do anything. POST is a
request, not a response.

if you want to re-post data you need to look at a client-side
alternative using javascript (or applets - flash, java, etc)

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



Re: [PHP] Header() - POST

2008-09-05 Thread Luke
POST requests in Ajax (or without in js) is straight forward. On the  
iPod now but I'll POST an example later. Get it?


Luke Slater
Lead Developer
NuVoo

On 5 Sep 2008, at 18:14, mike [EMAIL PROTECTED] wrote:

On Fri, Sep 5, 2008 at 9:20 AM, Boyd, Todd M. [EMAIL PROTECTED]  
wrote:


On a side note... in the future, if you find that a particular  
process
calls for POSTing to a different page, the cURL library (which I  
believe
is now included with PHP by default in v5.x+) can accomplish a  
plethora

of wonderful stuff that would ordinarily be handled by a browser
(POSTing, basic HTTP authentication, SSL certs, etc.).


correct: curl is king for that

OP: sending POST to the browser doesn't do anything. POST is a
request, not a response.

if you want to re-post data you need to look at a client-side
alternative using javascript (or applets - flash, java, etc)

--
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 Redirect

2008-05-28 Thread Robert Cummings

On Tue, 2008-05-27 at 20:50 +0100, Stut wrote:
 On 27 May 2008, at 19:18, Robert Cummings wrote:
  On Tue, 2008-05-27 at 18:04 +0100, Stut wrote:
  On 27 May 2008, at 17:54, Robert Cummings wrote:
  On Tue, 2008-05-27 at 17:10 +0100, Stut wrote:
  On 27 May 2008, at 17:06, Yui Hiroaki wrote:
  I would like to have some question.
 
  For example,
  I am in http://example.com/?12324242
 
  I would like to REDIRECT from  http://example.com/?1312323232
  to  http://example.com/
 
  I can REDIRECT from http://example.com/index.php to http://example.com
 
 
  Please do tell me how I can redirect!
 
 
  This is the sample what I test below!
 
  ?php
  if ($_SERVER['REQUEST_URI'] == '/index.php') {
  header(HTTP/1.1 301 Moved Permanently);
  header(Location: http:///example.com/;);
  exit();
  }
  ?
 
  1) Why? Redirects should be avoided where possible for performance
  reasons.
 
  Didn't this topic get covered several months back. I always do
  redirects
  so as not to bugger browser history, titles, indexing, etc. If  
  someone
  requests a page and they need to be logged in, I redirect to the  
  login
  page, I never just present the login page... that's just incorrect
  from
 
  Personally I tend to only use redirects when a form handler has done
  it's job to avoid evil messages when the user hits back. However, I
  have used both redirected and non-redirected login workflows in the
  past for various reasons, and I don't believe there is a standard
  way to do it. It depends on how the site will be used and by whom.
 
  a hierarchical and semantic point of view. Similarly, if I'm doing  
  404
  handling with fuzzy request sniffing to determine what was actually
  requested, I again perform a redirect once I've ascertained what was
  probably desired. If you don't, then Google and other search engines
  will index these malformed URLs instead of the correct URL.
 
  The correct response to a 404 page is 404. No arguments. If you
  redirect missing pages then your site effectively contains an  
  infinite
  number of pages. By all means display a useful page when you return
  your 404 but not marking it as a missing page does little if anything
  for your SEO rank and absolutely nothing for your users.
 
  404 Not Found, but it was found, but it's not where you asked for  
  it,
  it's over there... we've permanently moved it from here to there (even
  if only virtually)... let's redirect you to the correct location.  
  Since
  you perform a redirect to the correct location, the content is
  appropriately indexed where it actually exists. If you return a 404
  status I'm pretty sure Google discards the content.
 
 If you can successfully fulfil the request then it's not a 404, but I  
 would question why you're getting requests for URLs that don't exist  
 but that you can accurately service. If you're using the URL as a  
 search field then your site truly has no missing pages.
 
 However, in that case it's unlikely you'll be redirecting since for a  
 lot of queries you'll end up with multiple results meaning you're not  
 accurately fulfilling the request unless there's only one result from  
 the search. In that case I would agree that a redirect is the done  
 thing - except where the user got there by doing a search, which is  
 where things get cloudy as some would say it's appropriate to show  
 search results since that's the reasonable user expectation, and  
 others would say it should redirect to the single result - where I'd  
 come down on that would depend on the content and average user profile.
 
 *breath!*
 
 If you return a 404 Google does indeed discard the content - that's  
 the logical thing for it to do.  301's allow it to reduce the URLs  
 used to access your site to a core set of real content. Given that,  
 I agree to your premise that if you can successfully fulfil the  
 request by redirecting then you should, but only if it's an accurate  
 response to the request and not a best guess. Best guesses should be  
 presented to the user (and Google) as a page suggesting content and  
 providing other ways to find it if your suggestion is not correct.
 
 I'm starting to ramble so I'll stop here. I hope the point I'm making  
 is clear in there somewhere.
 
  IMHO if you're going to use a semantic argument to defend one point
  you need to carry that attitude throughout.
 
  My semantic argument is still intact. If I found it, then it's not
  deserving of 404 Not Found status. Sure it may not be at the  
  requested
  location, but that's what the moved status is for.
 
 The 301 status code was created so web developers can re-organise  
 their websites without adversely affecting the user experience. A side  
 effect of this is that search engines also use them to keep their  
 index up to date without affecting the sites ranking.
 
  Here's a physical world analogy. Walk into a hardware store ask for
  object X. If they have it they will tell you. If they don't then  
  

Re: [PHP] Header Redirect

2008-05-27 Thread Robert Cummings

On Tue, 2008-05-27 at 17:10 +0100, Stut wrote:
 On 27 May 2008, at 17:06, Yui Hiroaki wrote:
  I would like to have some question.
 
  For example,
  I am in http://example.com/?12324242
 
  I would like to REDIRECT from  http://example.com/?1312323232
  to  http://example.com/
 
  I can REDIRECT from http://example.com/index.php to http://example.com
 
 
  Please do tell me how I can redirect!
 
 
  This is the sample what I test below!
 
  ?php
  if ($_SERVER['REQUEST_URI'] == '/index.php') {
   header(HTTP/1.1 301 Moved Permanently);
   header(Location: http:///example.com/;);
   exit();
  }
  ?
 
 1) Why? Redirects should be avoided where possible for performance  
 reasons.

Didn't this topic get covered several months back. I always do redirects
so as not to bugger browser history, titles, indexing, etc. If someone
requests a page and they need to be logged in, I redirect to the login
page, I never just present the login page... that's just incorrect from
a hierarchical and semantic point of view. Similarly, if I'm doing 404
handling with fuzzy request sniffing to determine what was actually
requested, I again perform a redirect once I've ascertained what was
probably desired. If you don't, then Google and other search engines
will index these malformed URLs instead of the correct URL.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Header Redirect

2008-05-27 Thread Stut

On 27 May 2008, at 17:45, Yui Hiroaki wrote:

I try it following your adivice;



Code***
?php
$uuu=$_SERVER[QUERY_STRING];

if ($_SERVER['REQUEST_URI'] == '/index.php'.?.$uuu) {
 header(HTTP/1.1 301 Moved Permanently);
 header(Location: http://example.com/;);
 exit();
}
?

But I still need toconfigure below;
http://example/index.php?123233 and http://example/index.php/?123233



Can you help me?


?php
  if (strlen($_SERVER['QUERY_STRING'])  0)
  {
// The third parameter of the header function can be
// used to set the response code.
header('Location: http://example.com/', true, 301);

// You really should output something here so that in
// the unlikely event the client doesn't auto-follow
// the redirect the user is not left in the lurch.
echo 'Moved a href=http://example.com/;here/a';

exit;
  }
?

Rocket science it ain't!

But I repeat... this seems to be a completely pointless redirect. The  
user is already requesting the index page, so why redirect them back  
to the index page?


-Stut

--
http://stut.net/


2008/5/28 Stut [EMAIL PROTECTED]:

On 27 May 2008, at 17:06, Yui Hiroaki wrote:


I would like to have some question.

For example,
I am in http://example.com/?12324242

I would like to REDIRECT from  http://example.com/?1312323232
to  http://example.com/

I can REDIRECT from http://example.com/index.php to http://example.com


Please do tell me how I can redirect!


This is the sample what I test below!

?php
if ($_SERVER['REQUEST_URI'] == '/index.php') {
header(HTTP/1.1 301 Moved Permanently);
header(Location: http:///example.com/;);
exit();
}
?


1) Why? Redirects should be avoided where possible for performance  
reasons.


2) If you have to then the code you have will work but you need to  
check

$_SERVER['QUERY_STRING'] rather than REQUEST_URI.

-Stut

--
http://stut.net/




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



Re: [PHP] Header Redirect

2008-05-27 Thread Stut

On 27 May 2008, at 17:54, Robert Cummings wrote:

On Tue, 2008-05-27 at 17:10 +0100, Stut wrote:

On 27 May 2008, at 17:06, Yui Hiroaki wrote:

I would like to have some question.

For example,
I am in http://example.com/?12324242

I would like to REDIRECT from  http://example.com/?1312323232
to  http://example.com/

I can REDIRECT from http://example.com/index.php to http://example.com


Please do tell me how I can redirect!


This is the sample what I test below!

?php
if ($_SERVER['REQUEST_URI'] == '/index.php') {
header(HTTP/1.1 301 Moved Permanently);
header(Location: http:///example.com/;);
exit();
}
?


1) Why? Redirects should be avoided where possible for performance
reasons.


Didn't this topic get covered several months back. I always do  
redirects

so as not to bugger browser history, titles, indexing, etc. If someone
requests a page and they need to be logged in, I redirect to the login
page, I never just present the login page... that's just incorrect  
from


Personally I tend to only use redirects when a form handler has done  
it's job to avoid evil messages when the user hits back. However, I  
have used both redirected and non-redirected login workflows in the  
past for various reasons, and I don't believe there is a standard  
way to do it. It depends on how the site will be used and by whom.



a hierarchical and semantic point of view. Similarly, if I'm doing 404
handling with fuzzy request sniffing to determine what was actually
requested, I again perform a redirect once I've ascertained what was
probably desired. If you don't, then Google and other search engines
will index these malformed URLs instead of the correct URL.


The correct response to a 404 page is 404. No arguments. If you  
redirect missing pages then your site effectively contains an infinite  
number of pages. By all means display a useful page when you return  
your 404 but not marking it as a missing page does little if anything  
for your SEO rank and absolutely nothing for your users.


IMHO if you're going to use a semantic argument to defend one point  
you need to carry that attitude throughout.


-Stut

--
http://stut.net/

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



Re: [PHP] Header Redirect

2008-05-27 Thread elk dolk
What about using .htaccess for redirection for example, to redirect a single 
page:

Redirect 301  /oldpage.html  http://www.example.com/newpage.html



Stut [EMAIL PROTECTED] wrote: CC: PHP General List php-general@lists.php.net
From: Stut [EMAIL PROTECTED]
To: Robert Cummings [EMAIL PROTECTED]
Date: Tue, 27 May 2008 18:04:02 +0100
Subject: Re: [PHP] Header Redirect

 On 27 May 2008, at 17:54, Robert Cummings wrote:
 On Tue, 2008-05-27 at 17:10 +0100, Stut wrote:
 On 27 May 2008, at 17:06, Yui Hiroaki wrote:
 I would like to have some question.

 For example,
 I am in http://example.com/?12324242

 I would like to REDIRECT from  http://example.com/?1312323232
 to  http://example.com/

 I can REDIRECT from http://example.com/index.php to http://example.com


 Please do tell me how I can redirect!


 This is the sample what I test below!

  if ($_SERVER['REQUEST_URI'] == '/index.php') {
 header(HTTP/1.1 301 Moved Permanently);
 header(Location: http:///example.com/;);
 exit();
 }
 ?

 1) Why? Redirects should be avoided where possible for performance
 reasons.

 Didn't this topic get covered several months back. I always do  
 redirects
 so as not to bugger browser history, titles, indexing, etc. If someone
 requests a page and they need to be logged in, I redirect to the login
 page, I never just present the login page... that's just incorrect  
 from

Personally I tend to only use redirects when a form handler has done  
it's job to avoid evil messages when the user hits back. However, I  
have used both redirected and non-redirected login workflows in the  
past for various reasons, and I don't believe there is a standard  
way to do it. It depends on how the site will be used and by whom.

 a hierarchical and semantic point of view. Similarly, if I'm doing 404
 handling with fuzzy request sniffing to determine what was actually
 requested, I again perform a redirect once I've ascertained what was
 probably desired. If you don't, then Google and other search engines
 will index these malformed URLs instead of the correct URL.

The correct response to a 404 page is 404. No arguments. If you  
redirect missing pages then your site effectively contains an infinite  
number of pages. By all means display a useful page when you return  
your 404 but not marking it as a missing page does little if anything  
for your SEO rank and absolutely nothing for your users.

IMHO if you're going to use a semantic argument to defend one point  
you need to carry that attitude throughout.

-Stut

-- 
http://stut.net/

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



   

Re: [PHP] Header Redirect

2008-05-27 Thread Robert Cummings

On Tue, 2008-05-27 at 18:04 +0100, Stut wrote:
 On 27 May 2008, at 17:54, Robert Cummings wrote:
  On Tue, 2008-05-27 at 17:10 +0100, Stut wrote:
  On 27 May 2008, at 17:06, Yui Hiroaki wrote:
  I would like to have some question.
 
  For example,
  I am in http://example.com/?12324242
 
  I would like to REDIRECT from  http://example.com/?1312323232
  to  http://example.com/
 
  I can REDIRECT from http://example.com/index.php to http://example.com
 
 
  Please do tell me how I can redirect!
 
 
  This is the sample what I test below!
 
  ?php
  if ($_SERVER['REQUEST_URI'] == '/index.php') {
  header(HTTP/1.1 301 Moved Permanently);
  header(Location: http:///example.com/;);
  exit();
  }
  ?
 
  1) Why? Redirects should be avoided where possible for performance
  reasons.
 
  Didn't this topic get covered several months back. I always do  
  redirects
  so as not to bugger browser history, titles, indexing, etc. If someone
  requests a page and they need to be logged in, I redirect to the login
  page, I never just present the login page... that's just incorrect  
  from
 
 Personally I tend to only use redirects when a form handler has done  
 it's job to avoid evil messages when the user hits back. However, I  
 have used both redirected and non-redirected login workflows in the  
 past for various reasons, and I don't believe there is a standard  
 way to do it. It depends on how the site will be used and by whom.
 
  a hierarchical and semantic point of view. Similarly, if I'm doing 404
  handling with fuzzy request sniffing to determine what was actually
  requested, I again perform a redirect once I've ascertained what was
  probably desired. If you don't, then Google and other search engines
  will index these malformed URLs instead of the correct URL.
 
 The correct response to a 404 page is 404. No arguments. If you  
 redirect missing pages then your site effectively contains an infinite  
 number of pages. By all means display a useful page when you return  
 your 404 but not marking it as a missing page does little if anything  
 for your SEO rank and absolutely nothing for your users.

404 Not Found, but it was found, but it's not where you asked for it,
it's over there... we've permanently moved it from here to there (even
if only virtually)... let's redirect you to the correct location. Since
you perform a redirect to the correct location, the content is
appropriately indexed where it actually exists. If you return a 404
status I'm pretty sure Google discards the content.

 IMHO if you're going to use a semantic argument to defend one point  
 you need to carry that attitude throughout.

My semantic argument is still intact. If I found it, then it's not
deserving of 404 Not Found status. Sure it may not be at the requested
location, but that's what the moved status is for.

Here's a physical world analogy. Walk into a hardware store ask for
object X. If they have it they will tell you. If they don't then either
they will say, Sorry, we don't have that. I don't have a clue where you
can get it, or if they do know (and want to help) they'll say It's
over there at Rob's Hardware Store. What they almost certainly won't
say is hang on, then run over to Rob's hardware Store, buy item X, come
back and try to sell it to you. Almost certainly, but who knows, people
do weird things sometimes :)

So here's something else since you played the performance card. Click on
the following link and tell me where you end up when not already logged
in:

http://mail.google.com/mail/

I'm sure Google had a good reason for that behaviour, as in it's follows
more correctly the standard expected request behaviour, and I'm sure
they get a LOT of hits ;)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Header Redirect

2008-05-27 Thread Stut

On 27 May 2008, at 18:58, elk dolk wrote:
What about using .htaccess for redirection for example, to redirect  
a single page:


Redirect 301  /oldpage.html  http://www.example.com/newpage.html


I'm assuming the OP is actually doing something with that number  
before throwing it away. If not then the whole thing becomes a bit  
pointless.


-Stut

--
http://stut.net/

Stut [EMAIL PROTECTED] wrote: CC: PHP General List php-general@lists.php.net 


From: Stut [EMAIL PROTECTED]
To: Robert Cummings [EMAIL PROTECTED]
Date: Tue, 27 May 2008 18:04:02 +0100
Subject: Re: [PHP] Header Redirect

On 27 May 2008, at 17:54, Robert Cummings wrote:

On Tue, 2008-05-27 at 17:10 +0100, Stut wrote:

On 27 May 2008, at 17:06, Yui Hiroaki wrote:

I would like to have some question.

For example,
I am in http://example.com/?12324242

I would like to REDIRECT from  http://example.com/?1312323232
to  http://example.com/

I can REDIRECT from http://example.com/index.php to http://example.com


Please do tell me how I can redirect!


This is the sample what I test below!


if ($_SERVER['REQUEST_URI'] == '/index.php') {

header(HTTP/1.1 301 Moved Permanently);
header(Location: http:///example.com/;);
exit();
}
?


1) Why? Redirects should be avoided where possible for performance
reasons.


Didn't this topic get covered several months back. I always do
redirects
so as not to bugger browser history, titles, indexing, etc. If  
someone
requests a page and they need to be logged in, I redirect to the  
login

page, I never just present the login page... that's just incorrect
from


Personally I tend to only use redirects when a form handler has done
it's job to avoid evil messages when the user hits back. However, I
have used both redirected and non-redirected login workflows in the
past for various reasons, and I don't believe there is a standard
way to do it. It depends on how the site will be used and by whom.

a hierarchical and semantic point of view. Similarly, if I'm doing  
404

handling with fuzzy request sniffing to determine what was actually
requested, I again perform a redirect once I've ascertained what was
probably desired. If you don't, then Google and other search engines
will index these malformed URLs instead of the correct URL.


The correct response to a 404 page is 404. No arguments. If you
redirect missing pages then your site effectively contains an infinite
number of pages. By all means display a useful page when you return
your 404 but not marking it as a missing page does little if anything
for your SEO rank and absolutely nothing for your users.

IMHO if you're going to use a semantic argument to defend one point
you need to carry that attitude throughout.

-Stut

--
http://stut.net/

--
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 Redirect

2008-05-27 Thread Stut

On 27 May 2008, at 19:18, Robert Cummings wrote:

On Tue, 2008-05-27 at 18:04 +0100, Stut wrote:

On 27 May 2008, at 17:54, Robert Cummings wrote:

On Tue, 2008-05-27 at 17:10 +0100, Stut wrote:

On 27 May 2008, at 17:06, Yui Hiroaki wrote:

I would like to have some question.

For example,
I am in http://example.com/?12324242

I would like to REDIRECT from  http://example.com/?1312323232
to  http://example.com/

I can REDIRECT from http://example.com/index.php to http://example.com


Please do tell me how I can redirect!


This is the sample what I test below!

?php
if ($_SERVER['REQUEST_URI'] == '/index.php') {
header(HTTP/1.1 301 Moved Permanently);
header(Location: http:///example.com/;);
exit();
}
?


1) Why? Redirects should be avoided where possible for performance
reasons.


Didn't this topic get covered several months back. I always do
redirects
so as not to bugger browser history, titles, indexing, etc. If  
someone
requests a page and they need to be logged in, I redirect to the  
login

page, I never just present the login page... that's just incorrect
from


Personally I tend to only use redirects when a form handler has done
it's job to avoid evil messages when the user hits back. However, I
have used both redirected and non-redirected login workflows in the
past for various reasons, and I don't believe there is a standard
way to do it. It depends on how the site will be used and by whom.

a hierarchical and semantic point of view. Similarly, if I'm doing  
404

handling with fuzzy request sniffing to determine what was actually
requested, I again perform a redirect once I've ascertained what was
probably desired. If you don't, then Google and other search engines
will index these malformed URLs instead of the correct URL.


The correct response to a 404 page is 404. No arguments. If you
redirect missing pages then your site effectively contains an  
infinite

number of pages. By all means display a useful page when you return
your 404 but not marking it as a missing page does little if anything
for your SEO rank and absolutely nothing for your users.


404 Not Found, but it was found, but it's not where you asked for  
it,

it's over there... we've permanently moved it from here to there (even
if only virtually)... let's redirect you to the correct location.  
Since

you perform a redirect to the correct location, the content is
appropriately indexed where it actually exists. If you return a 404
status I'm pretty sure Google discards the content.


If you can successfully fulfil the request then it's not a 404, but I  
would question why you're getting requests for URLs that don't exist  
but that you can accurately service. If you're using the URL as a  
search field then your site truly has no missing pages.


However, in that case it's unlikely you'll be redirecting since for a  
lot of queries you'll end up with multiple results meaning you're not  
accurately fulfilling the request unless there's only one result from  
the search. In that case I would agree that a redirect is the done  
thing - except where the user got there by doing a search, which is  
where things get cloudy as some would say it's appropriate to show  
search results since that's the reasonable user expectation, and  
others would say it should redirect to the single result - where I'd  
come down on that would depend on the content and average user profile.


*breath!*

If you return a 404 Google does indeed discard the content - that's  
the logical thing for it to do.  301's allow it to reduce the URLs  
used to access your site to a core set of real content. Given that,  
I agree to your premise that if you can successfully fulfil the  
request by redirecting then you should, but only if it's an accurate  
response to the request and not a best guess. Best guesses should be  
presented to the user (and Google) as a page suggesting content and  
providing other ways to find it if your suggestion is not correct.


I'm starting to ramble so I'll stop here. I hope the point I'm making  
is clear in there somewhere.



IMHO if you're going to use a semantic argument to defend one point
you need to carry that attitude throughout.


My semantic argument is still intact. If I found it, then it's not
deserving of 404 Not Found status. Sure it may not be at the  
requested

location, but that's what the moved status is for.


The 301 status code was created so web developers can re-organise  
their websites without adversely affecting the user experience. A side  
effect of this is that search engines also use them to keep their  
index up to date without affecting the sites ranking.



Here's a physical world analogy. Walk into a hardware store ask for
object X. If they have it they will tell you. If they don't then  
either
they will say, Sorry, we don't have that. I don't have a clue where  
you

can get it, or if they do know (and want to help) they'll say It's
over there at Rob's Hardware Store. What they almost 

Re: [PHP] header('Location:') works locally but not remotely

2007-04-16 Thread Dave Goodchild

Provide some code...?


Re: [PHP] header('Location:') works locally but not remotely

2007-04-16 Thread Richard Lynch
On Mon, April 16, 2007 11:16 am, Ross wrote:
 any reason why this should be?

Things that could go wrong:

1. output_buffering can make header work when it shouldn't because
it will buffer HTML (or other) output and then it works

2. Location: URLs are supposed to be full-blown URLs.  Maybe it
works when they're not, and maybe it doesn't.  Depends more on the
browser than on anything, but who knows fomr what little you've given
us...

3. Remote server *could* have header() function disabled in php.ini --
unlikely, but possible.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] header

2006-11-24 Thread Richard Lynch
On Fri, November 24, 2006 9:13 am, João Cândido de Souza Neto wrote:
 In my index.php file of my system i have got just one php tag in which
 it
 starts a smarty object, make a lot of includes of templates and use
 $smarty-display(index.tpl) to show the result.

 Until i know, smarty do not send any data to browser before display
 method,
 but, in some cases i must do header(location: sompage.php) and it

Nitpick:
header(Location: ...);
is supposed to have an absolute URI, i.e., a full URL with http://
and everything.

 gives the
 follow error:

 Warning: Cannot modify header information - headers already sent by
 (output
 started at
 /usr/local/apache2/htdocs/www2.superbanco.com.br/html/index.php:1) in
 /usr/local/apache2/htdocs/www2.superbanco.com.br/html/modules/loja/identificacao.php
 on line 15

To anybody else stuck on a similar problem, the error message requires
a bit of re-reading to pull it all out into sense, but literally
EVERYTHING you need to work out what went wrong is in this error
message...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] header lost session variables.

2006-08-14 Thread BBC
 Hi guys.
 
 Anyone here know why in some cases when i use (header(Location: ???); the 
 system lost the session variables?
 
 Any tips will be apreciated.
 Thanks in advantge.

Please tell me the cases you mean..!

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



Re: [PHP] header lost session variables.

2006-08-14 Thread Jo�o C�ndido de Souza Neto
I´m in the follow location:

https://www2.../?modulo=seguroacao=identifica

And in my script i use header(Location: 
./?modulo=seguroacao=novo_cadastro)

When it run, my system lost all session variables.

BBC [EMAIL PROTECTED] escreveu na mensagem 
news:[EMAIL PROTECTED]
 Hi guys.

 Anyone here know why in some cases when i use (header(Location: ???); 
 the
 system lost the session variables?

 Any tips will be apreciated.
 Thanks in advantge.

 Please tell me the cases you mean..! 

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



Re: [PHP] header lost session variables.

2006-08-14 Thread J R

On 8/15/06, João Cândido de Souza Neto [EMAIL PROTECTED] wrote:


I´m in the follow location:

https://www2.../?modulo=seguroacao=identifica

And in my script i use header(Location:
./?modulo=seguroacao=novo_cadastro)



i normally do

header(Location: ?modulo=seguroacao=novo_cadastro);

thats with out the ./ but i'm not sure if its has any effect. try it out
anyway. i could not think of any reason why your session variables
will disappear,
unless you don't do session start() :) hehehe...(in which of course you do)

if possible could you paste some of your codes so others can take a look at
it.

When it run, my system lost all session variables.


BBC [EMAIL PROTECTED] escreveu na mensagem
news:[EMAIL PROTECTED]
 Hi guys.

 Anyone here know why in some cases when i use (header(Location: ???);
 the
 system lost the session variables?

 Any tips will be apreciated.
 Thanks in advantge.

 Please tell me the cases you mean..!

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





--
GMail Rocks!!!


Re: [PHP] header lost session variables.

2006-08-14 Thread Richard Lynch
On Mon, August 14, 2006 8:04 am, João Cândido de Souza Neto wrote:
 Anyone here know why in some cases when i use (header(Location:
 ???); the
 system lost the session variables?

Yes.

The browser gets headers such as this:

Location: http://example.com
Cookie: Example Value

*SOME* browsers, as soon as they see that Location: line, will
IMMEDIATELY go to the other URL, ignoring the Cookie line.

Don't do that.

If the Location: is your own PHP code, just include() it and do exit;
and call it fixed.

You can also try to throw a session_write_close (?) before the
header(Location: ) line -- Others have posted some success with
that, but I suspect it won't fix things for EVERY browser out there.

-- 
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 lost session variables.

2006-08-14 Thread Richard Lynch
On Mon, August 14, 2006 6:56 pm, J R wrote:
 On 8/15/06, João Cândido de Souza Neto [EMAIL PROTECTED]
 wrote:

 I´m in the follow location:

 https://www2.../?modulo=seguroacao=identifica

 And in my script i use header(Location:
 ./?modulo=seguroacao=novo_cadastro)


 i normally do

 header(Location: ?modulo=seguroacao=novo_cadastro);

 thats with out the ./ but i'm not sure if its has any effect. try it
 out
 anyway. i could not think of any reason why your session variables
 will disappear,
 unless you don't do session start() :) hehehe...(in which of course
 you do)

HTTP RFC Specs require that Location be a complete URL starting with
http://; so you're pretty much both making a fundamental error
here...

:-) :-) :-)

-- 
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(Location: ... or Header(Refresh: 0;...

2006-05-16 Thread Richard Lynch
On Tue, May 16, 2006 10:48 am, Kevin Davies wrote:
 header (Refresh: 0;
 URL=cart.php?action=addid=$referencec=$catp=$page);
 exit;

I don't think this is a real header -- just some made-up crapola
from MS that works on most browsers, from the bully-pulpit
principle.

You'd have to read the HTTP specs for yourself to work it out...

That said, if it's not working, then it's not working.

Location: *DOES* work.

-- 
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 WWW-Authenticate Question

2006-01-26 Thread Philip Hallstrom

I have been looking for this in several areas and I can't seem to find it.
I'm new to PHP (any programming since FORTRAN, really :) so please forgive
my ignorance.

I am trying to send username/password credentials to a web server using a
PHP script.  This is done to automatically log into a web camera from my
workstation.  I don't know if the header www-authenticate option is the
correct one (or if it's even possible) to use for this.


Depending on what you're doing it might be as easy as:

http://user:[EMAIL PROTECTED]/path?query=string

If all you need to do is suck down a page that would do it.  If your 
POSTING check the HTTP RFC for what headers to send...


-philip

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



Re: [PHP] header WWW-Authenticate Question

2006-01-26 Thread Richard Lynch
On Thu, January 26, 2006 1:02 pm, News1 wrote:
 I am trying to send username/password credentials to a web server
 using a
 PHP script.  This is done to automatically log into a web camera from
 my
 workstation.  I don't know if the header www-authenticate option is
 the
 correct one (or if it's even possible) to use for this.

I think www-authenticate is what the server sends to the browser, not
the other way around.

I'm guessing that since it's called PHP_AUTH_USER and PHP_AUTH_PW in
PHP, that you would need to send:

GET / HTTP/1.0
AUTH_USER: $username
PATH_PW: $password
Host: example.com

You may also want to look into:
http://php.net/curl

-- 
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 WWW-Authenticate Question

2006-01-26 Thread Manuel Lemos
Hello,

 I am trying to send username/password credentials to a web server using a
 PHP script.  This is done to automatically log into a web camera from my
 workstation.  I don't know if the header www-authenticate option is the
 correct one (or if it's even possible) to use for this.

You may want to try this HTTP client class. It comes with HTTP
authentication support using the SASL library package. The example
test_http.php has some comments to let you know how to configure the
authetication support:

http://www.phpclasses.org/httpclient

http://www.phpclasses.org/sasl


-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



Re: [PHP] HEADER + target?

2005-09-19 Thread Jasper Bryant-Greene

Gustav Wiberg wrote:

I think this question has been on the list before, but I can't find it.
I want to do like this:

script language=Javascript
parent.mainFrame.location = 'fire.php';
/script

...but in PHP with the  HEADER() - function...


Not that hard to find... http://php.net/header

header('Location: http://www.example.com/fire.php');

You should put the full URI, including http:// and your domain. Not 
doing so violates the HTTP spec.


If you want to signal that the resource has permanently moved, put this 
before the above call:


header('HTTP/1.1 301 Moved Permanently');

--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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



Re: [PHP] HEADER + target?

2005-09-19 Thread Gustav Wiberg
- Original Message - 
From: Jasper Bryant-Greene [EMAIL PROTECTED]

To: PHP General php-general@lists.php.net
Sent: Monday, September 19, 2005 10:31 AM
Subject: Re: [PHP] HEADER + target?



Gustav Wiberg wrote:

I think this question has been on the list before, but I can't find it.
I want to do like this:

script language=Javascript
parent.mainFrame.location = 'fire.php';
/script

...but in PHP with the  HEADER() - function...


Not that hard to find... http://php.net/header

header('Location: http://www.example.com/fire.php');

You should put the full URI, including http:// and your domain. Not doing 
so violates the HTTP spec.


If you want to signal that the resource has permanently moved, put this 
before the above call:


header('HTTP/1.1 301 Moved Permanently');

--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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



--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.1/104 - Release Date: 2005-09-16



Hi again!

I wasn't clear enough.. hm.. I meant that lets say, I have two frames = 
leftFrame and rightFrame.


I'm in leftFrame and want to redirect to a page called fire.php in the 
rightFrame.
If I use HEADER(Location: fire.phg); then the current frame will be 
updated (leftFrame), I want to update the rightFrame FROM the leftFrame...


/G
http://www.varupiraten.se/




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



Re: [PHP] HEADER + target?

2005-09-19 Thread Jasper Bryant-Greene

Gustav Wiberg wrote:
I wasn't clear enough.. hm.. I meant that lets say, I have two frames = 
leftFrame and rightFrame.


I'm in leftFrame and want to redirect to a page called fire.php in the 
rightFrame.
If I use HEADER(Location: fire.phg); then the current frame will be 
updated (leftFrame), I want to update the rightFrame FROM the leftFrame...


Then use JavaScript as you indicated in your original message. Remember 
PHP is executed on the server side so has no knowledge of browser things 
like frames.


--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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



Re: [PHP] header, location: mailto abd browsers

2005-09-07 Thread Mikey

Bernard Perrot wrote:


hello,

I have a little problem with this kind of script :

?php
function mailto ($addr) {
 Header (Location: mailto:$addr;);
}

mailto([EMAIL PROTECTED]);
?

When called from an html page, it open correctly un MUA from mailing, 
but with some browser (mozilla for example), the calling page is still 
displayed, and with some others (firefox for example), a new blank 
page is displayed (and I don't want).


Any ideas about the problem ? How to solve it ?

Best regards,


From the HTTP RFC:

The Location response-header field is used to redirect the recipient to 
a location other than the Request-URI for completion of the request or 
identification of a new resource. For 201 (Created) responses, the 
Location is that of the new resource which was created by the request. 
For 3xx responses, the location SHOULD indicate the server's preferred 
URI for automatic redirection to the resource. The field value consists 
of a single absolute URI.


  Location   = Location : absoluteURI

Your script doesn't appear to be trying to do a re-direct, but rather open a 
client side e-mail - if you want to do this, then you will need to use 
JavaScript on the client side.

HTH,

Mikey


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



  1   2   3   4   >