Code Comments
Programming Forum and web based access to our favorite programming groups.
i have a registration page which is a self submitting form <form
action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST"
id="test2" name="registrationform">
where in a user fill a form, after the data has been inserted to a
database i would like to redirect the user to a different
page. i am not able to use header(Location: filename.html) as i have
echo statements before and i get a message that headers
have already been sent. so due to this i am using
echo (" <meta http-equiv='refresh' content='0;url=thankyou.php?
firstname=$firstname'> "); this works perfectly fine.
however if a user disables meta refresh which is a very small
possibility the above meta tag would not execute to avoid such
a situation i would like to use echo statements to create a new page
which would have html tags and display a similar page to
thankyou.php
in my case the php code is placed in the middle of the page which
displays messages that a user did not enter in the form.
the page is so structured that there is some information written using
html tags followed by the registration questions where
the php code is present to validate. i have used
echo (" <meta http-equiv='refresh' content='0;url=thankyou.php?fname=
$fname'> ");
redirectingthepage();
exit;
i have used the above code so that even if the echo (" <meta http-
equiv='refresh' content='0;url=thankyou.php?fname=$fname'>
"); is not executed the redirectingthepage() function will be
executed.
my question is due to the structure of the page whatever text is
present before the form that text is appearing again
followed by the text i have inside redirectingthepage() function, i do
not want this to happen. i would like what is written
in redirectingthepage() function only to appear. i have defined
redirectingthepage() function in a separate file and i am
calling the file which has redirectingthepage() function by using
include statement in the registration page.
please advice how i can display what is defined in
redirectingthepage() function ONLY if the refresh is disabled by the
user
thanks.
Post Follow-up to this message..oO(Sudhakar)
>i have a registration page which is a self submitting form <form
>action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST"
>
>id="test2" name="registrationform">
>
>where in a user fill a form, after the data has been inserted to a
>database i would like to redirect the user to a different
>
>page. i am not able to use header(Location: filename.html) as i have
>echo statements before and i get a message that headers
Then re-order your code. What's the purpose of echoing something, which
wouldn't be seen at all? Keep the processing and branching logic on top
of the script before any output. Structured and procedural programming
helps a lot with this.
If you can't do that for whatever reason, enable output buffering. Then
you can print out stuff and still send HTTP headers.
>have already been sent. so due to this i am using
>
>echo (" <meta http-equiv='refresh' content='0;url=thankyou.php?
>firstname=$firstname'> "); this works perfectly fine.
This is not only unreliable, it would also break the browser's back
button. Never do that. And BTW: The purpose of this meta thingy is to
_refresh_ a page, not to redirect to another. Drop it and use a proper
HTTP redirect.
Micha
Post Follow-up to this messageOn Mar 9, 1:19=A0pm, Michael Fesser <neti...@gmx.de> wrote:
> .oO(Sudhakar)
>
>
>
>
>
> Then re-order your code. What's the purpose of echoing something, which
> wouldn't be seen at all? Keep the processing and branching logic on top
> of the script before any output. Structured and procedural programming
> helps a lot with this.
>
> If you can't do that for whatever reason, enable output buffering. Then
> you can print out stuff and still send HTTP headers.
>
>
>
> This is not only unreliable, it would also break the browser's back
> button. Never do that. And BTW: The purpose of this meta thingy is to
> _refresh_ a page, not to redirect to another. Drop it and use a proper
> HTTP redirect.
>
> Micha
You should use something like:
header('Location: thankyou.php');
die();
Rgds,
Alex
Post Follow-up to this message..oO(ajtrichards@googlemail.com)
>You should use something like:
>
>header('Location: thankyou.php');
>die();
Besides the missing scheme and hostname - this was what the OP was
trying, but there was some output _before_ the header() call.
Micha
Post Follow-up to this messageGreetings, Michael Fesser. In reply to Your message dated Monday, March 10, 2008, 03:07:19, > .oO(ajtrichards@googlemail.com) > Besides the missing scheme and hostname - this was what the OP was > trying, but there was some output _before_ the header() call. And according to PHP specification, "Location" header must contain fully qualified address, including protocol identificator and host name. BTW, nothing wrong in sending some output before header() call... if You REALLY know what You doing. That all depends on Your host configuration. -- Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru>
Post Follow-up to this messageAnrDaemon wrote: > Greetings, Michael Fesser. > In reply to Your message dated Monday, March 10, 2008, 03:07:19, > > > > > And according to PHP specification, "Location" header must contain fully > qualified address, including protocol identificator and host name. > > BTW, nothing wrong in sending some output before header() call... if You > REALLY know what You doing. That all depends on Your host configuration. > > Wrong. From the PHP manual under the header function: "Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP." You CANNOT send output before a header() call. And don't try to claim you can use ob_start(), etc. That just masks the problem, not solves it. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
Post Follow-up to this messageGreetings, Jerry Stuckle. In reply to Your message dated Monday, March 31, 2008, 01:57:38, > AnrDaemon wrote: > Wrong. From the PHP manual under the header function: > "Remember that header() must be called before any actual output is sent, > either by normal HTML tags, blank lines in a file, or from PHP." > You CANNOT send output before a header() call. And don't try to claim > you can use ob_start(), etc. That just masks the problem, not solves it. die(0); -- Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru>
Post Follow-up to this messageAnrDaemon wrote: > Greetings, Jerry Stuckle. > In reply to Your message dated Monday, March 31, 2008, 01:57:38, > > > > > > die(0); > > Which doesn't allow the header() call to be sent, among other things. And even then, it doesn't guarantee the headers have NOT been sent already. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
Post Follow-up to this messageGreetings, Jerry Stuckle. In reply to Your message dated Monday, March 31, 2008, 21:26:13, > Which doesn't allow the header() call to be sent, among other things. > And even then, it doesn't guarantee the headers have NOT been sent already.[/color ] That was order for Your death. You're just a disturbance and thinking that only Your point of view is right. So, please die without raising any errorlevels. I cannot send any output to the user when I have output buffering enabled (unless I use explicit ob_flush() call). What I mean "If You know what You doing". And I'm surely know what I doing by zipping output to help ppl get m y pages quickly and successfully. I was not very precise in my words using "sending" instead of "printing", an d I apologise for that to the rest of newsgroup. End of statement. -- Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru>
Post Follow-up to this messageAnrDaemon wrote: > Greetings, Jerry Stuckle. > In reply to Your message dated Monday, March 31, 2008, 21:26:13, > > > > > > That was order for Your death. You're just a disturbance and thinking that > only Your point of view is right. So, please die without raising any > errorlevels. > > I cannot send any output to the user when I have output buffering enabled > (unless I use explicit ob_flush() call). What I mean "If You know what You > doing". And I'm surely know what I doing by zipping output to help ppl get my > pages quickly and successfully. > > I was not very precise in my words using "sending" instead of "printing", and > I apologise for that to the rest of newsgroup. > > End of statement. > > Good programmers fix errors. Sloppy programmers hide them with thinks like ob_start(). -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.