470,586 Members | 1,349 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,586 developers. It's quick & easy.

can't get header() to redirect

forgive my ignorance, as I'm new to php coming from a ms background...

If I create a page named redirect.php and it's only content is:
<?php
header("Location: http://www.google.com");
?>
Should it not redirect to www.google.com? I can't get the header()
function to redirect.

I'm trying to take an online reservation... the customer fills out
contact and billing info at SignUp.php. The form on SignUp.php
submits to Confirm.php, where I perform validation.

If the input fails validation, I want to redirect back to SignUp.php.
Otherwise I will display the input for confirmation before processing
the order. Maybe I'm implementing this wrong... using asp thinking
for a php implementation, but I think this should be simple and I must
be missing something.

thanks.
Jul 17 '05 #1
10 6123
Bob Garbados wrote:

[...]
If the input fails validation, I want to redirect back to SignUp.php.
Otherwise I will display the input for confirmation before processing
the order. Maybe I'm implementing this wrong... using asp thinking
for a php implementation, but I think this should be simple and I must
be missing something.
Instead of redirecting (do you get any error messages by the way?) why
don't you re-show the form if it's not filled in correctly? And now
you're at it, show the user what's wrong (e.g.: what he didn't fill in)
thanks.


HTH,
Sebastian
--
The most likely way for the world to be destroyed,
most experts agree, is by accident.
That's where we come in; we're computer professionals.
We cause accidents.
--Nathaniel Borenstein
Jul 17 '05 #2
"Bob Garbados" wrote:
forgive my ignorance, as Iím new to php coming from a ms
background...

If I create a page named redirect.php and itís only content is:
<?php
header("Location: http://www.google.com");
?>
Should it not redirect to www.google.com? I canít get the
header()
function to redirect.

Iím trying to take an online reservation... the customer fills
out
contact and billing info at SignUp.php. The form on SignUp.php
submits to Confirm.php, where I perform validation.

If the input fails validation, I want to redirect back to SignUp.php. Otherwise I will display the input for confirmation before processing the order. Maybe Iím implementing this wrong... using asp
thinking
for a php implementation, but I think this should be simple and I must be missing something.

thanks.


The normal way is to process the form on the same script, and redirect
only if everything is ok. The reason has to do with post variables,
and people going back to prev. page (complex but take my word for it).
If you redirect, make sure nothing has been written out (e.g. header
stuff, spaces, etc.). It should work. Please report the error you
get.

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-header-r...ict141549.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=473240
Jul 17 '05 #3
steve <Us************@dbForumz.com> wrote in message news:<41********@news.athenanews.com>...
"Bob Garbados" wrote:
> forgive my ignorance, as I?m new to php coming from a ms
> background...
>
> If I create a page named redirect.php and it?s only content is:
> <?php
> header("Location: http://www.google.com");
> ?>
> Should it not redirect to www.google.com? I can?t get the
> header()
> function to redirect.
>
> I?m trying to take an online reservation... the customer fills
> out
> contact and billing info at SignUp.php. The form on SignUp.php
> submits to Confirm.php, where I perform validation.
>
> If the input fails validation, I want to redirect back to

SignUp.php.
> Otherwise I will display the input for confirmation before

processing
> the order. Maybe I?m implementing this wrong... using asp
> thinking
> for a php implementation, but I think this should be simple and I

must
> be missing something.
>
> thanks.


The normal way is to process the form on the same script, and redirect
only if everything is ok. The reason has to do with post variables,
and people going back to prev. page (complex but take my word for it).
If you redirect, make sure nothing has been written out (e.g. header
stuff, spaces, etc.). It should work. Please report the error you
get.


Thanks...
I'm not seeing an error message, just a blank page. I'm testing it on
my hoster's server because I haven't configured IIS to suppport php
yet and I don't have a linux box set up yet. Is there something to
configure in php.ini to display error messages?

Let me see if I have this right... I have to post the form on
SignUp.php back to SignUp.php, perform the validation, and redirect to
the confirmation page if everything passes validation prior to the
<html> tag?

thanks again.
Jul 17 '05 #4
"Bob Garbados" wrote:
steve <Us************@dbForumz.com> wrote in message
news:<41********@news.athenanews.com>...
"Bob Garbados" wrote:
> forgive my ignorance, as I?m new to php coming from a ms
> background...
>
> If I create a page named redirect.php and it?s only content is: > <?php
> header("Location: http://www.google.com");
> ?>
> Should it not redirect to www.google.com? I can?t get the
> header()
> function to redirect.
>
> I?m trying to take an online reservation... the customer fills > out
> contact and billing info at SignUp.php. The form on SignUp.php > submits to Confirm.php, where I perform validation.
>
> If the input fails validation, I want to redirect back to SignUp.php.
> Otherwise I will display the input for confirmation before

processing
> the order. Maybe I?m implementing this wrong... using asp
> thinking
> for a php implementation, but I think this should be simple

and I
must
> be missing something.
>
> thanks.


The normal way is to process the form on the same script, and

redirect
only if everything is ok. The reason has to do with post

variables,
and people going back to prev. page (complex but take my word for

it).
If you redirect, make sure nothing has been written out (e.g.

header
stuff, spaces, etc.). It should work. Please report the error

you
get.


Thanks...
Iím not seeing an error message, just a blank page. Iím
testing it on
my hosterís server because I havenít configured IIS to
suppport php
yet and I donít have a linux box set up yet. Is there something
to
configure in php.ini to display error messages?

Let me see if I have this right... I have to post the form on
SignUp.php back to SignUp.php, perform the validation, and redirect

to the confirmation page if everything passes validation prior to the
<html> tag?

thanks again.


Hi Bob, surprised you get a blank page. Is there a URL or nothing at
all? Why donít you create a test script with just the header
statement and see how it works.

Yes, you redirect to the same page. So your form would say
<form action=íí method=post>
and you also would have a hidden field <input type=hidden....
which would be used in the validation to detect that the form has been
submitted. Then if everything is ok, you can redirect.

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-header-r...ict141549.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=473984
Jul 17 '05 #5
Thanks for your help.

I see the URL of the page containing the header() statement, but there's no
content... just whitespace. I created a script with just the header
statement earlier today and it worked without a hitch.

Any php script that I put on the server that has an error like a missing
semicolon, I just see a blank page and no error message.

Originally, my reasoning for having the form post to a different script is
because I will be creating 5 reservation forms for different events. All of
the forms have the same fields for contact info and billing info, they'll
just have different fields for information pertaining to each specific
event. So I wanted to keep all of the validation logic for the contact and
billing info in one spot and not have to maintain the code in five different
places. Am I correct in assuming I could accomplish this through some kind
of include file then?

"steve" <Us************@dbForumz.com> wrote in message
news:41**********@news.athenanews.com...
"Bob Garbados" wrote:
> steve <Us************@dbForumz.com> wrote in message
> news:<41********@news.athenanews.com>...
> > "Bob Garbados" wrote:
> > > forgive my ignorance, as I?m new to php coming from a ms
> > > background...
> > >
> > > If I create a page named redirect.php and it?s only content

> is:
> > > <?php
> > > header("Location: http://www.google.com");
> > > ?>
> > > Should it not redirect to www.google.com? I can?t get the
> > > header()
> > > function to redirect.
> > >
> > > I?m trying to take an online reservation... the customer

> fills
> > > out
> > > contact and billing info at SignUp.php. The form on

> SignUp.php
> > > submits to Confirm.php, where I perform validation.
> > >
> > > If the input fails validation, I want to redirect back to
> > SignUp.php.
> > > Otherwise I will display the input for confirmation before
> > processing
> > > the order. Maybe I?m implementing this wrong... using asp
> > > thinking
> > > for a php implementation, but I think this should be simple

> and I
> > must
> > > be missing something.
> > >
> > > thanks.
> >
> > The normal way is to process the form on the same script, and

> redirect
> > only if everything is ok. The reason has to do with post

> variables,
> > and people going back to prev. page (complex but take my word for

> it).
> > If you redirect, make sure nothing has been written out (e.g.

> header
> > stuff, spaces, etc.). It should work. Please report the error

> you
> > get.

>
> Thanks...
> I'm not seeing an error message, just a blank page. I'm
> testing it on
> my hoster's server because I haven't configured IIS to
> suppport php
> yet and I don't have a linux box set up yet. Is there something
> to
> configure in php.ini to display error messages?
>
> Let me see if I have this right... I have to post the form on
> SignUp.php back to SignUp.php, perform the validation, and redirect

to
> the confirmation page if everything passes validation prior to the
> <html> tag?
>
> thanks again.


Hi Bob, surprised you get a blank page. Is there a URL or nothing at
all? Why don't you create a test script with just the header
statement and see how it works.

Yes, you redirect to the same page. So your form would say
<form action='' method=post>
and you also would have a hidden field <input type=hidden....
which would be used in the validation to detect that the form has been
submitted. Then if everything is ok, you can redirect.

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-header-r...ict141549.html
Visit Topic URL to contact author (reg. req'd). Report abuse:

http://www.dbForumz.com/eform.php?p=473984
Jul 17 '05 #6
"Bob Garbados1" wrote:
Thanks for your help.

I see the URL of the page containing the header() statement, but
thereís no
content... just whitespace. I created a script with just the header statement earlier today and it worked without a hitch.

Any php script that I put on the server that has an error like a
missing
semicolon, I just see a blank page and no error message.

Originally, my reasoning for having the form post to a different
script is
because I will be creating 5 reservation forms for different events. All of
the forms have the same fields for contact info and billing info,
theyíll
just have different fields for information pertaining to each specific event. So I wanted to keep all of the validation logic for the
contact and
billing info in one spot and not have to maintain the code in five
different
places. Am I correct in assuming I could accomplish this through some kind
of include file then?

"steve" <Us************@dbForumz.com> wrote in message
news:41261df0

_2@news.athenanews.com...
"Bob Garbados" wrote:
> steve <Us************@dbForumz.com> wrote in message
> news:<41********@news.athenanews.com>...
> > "Bob Garbados" wrote:
> > > forgive my ignorance, as I?m new to php coming from a ms > > > background...
> > >
> > > If I create a page named redirect.php and it?s only content > is:
> > > <?php
> > > header("Location: http://www.google.com");
> > > ?>
> > > Should it not redirect to www.google.com? I can?t get the > > > header()
> > > function to redirect.
> > >
> > > I?m trying to take an online reservation... the customer > fills
> > > out
> > > contact and billing info at SignUp.php. The form on > SignUp.php
> > > submits to Confirm.php, where I perform validation. > > >
> > > If the input fails validation, I want to redirect back to > > SignUp.php.
> > > Otherwise I will display the input for confirmation before > > processing
> > > the order. Maybe I?m implementing this wrong... using asp > > > thinking
> > > for a php implementation, but I think this should be simple > and I
> > must
> > > be missing something.
> > >
> > > thanks.
> >
> > The normal way is to process the form on the same script, and > redirect
> > only if everything is ok. The reason has to do with post > variables,
> > and people going back to prev. page (complex but take my word for > it).
> > If you redirect, make sure nothing has been written out (e.g. > header
> > stuff, spaces, etc.). It should work. Please report the error > you
> > get.
>
> Thanks...
> Iím not seeing an error message, just a blank page. Iím > testing it on
> my hosterís server because I havenít configured IIS to > suppport php
> yet and I donít have a linux box set up yet. Is there something > to
> configure in php.ini to display error messages?
>
> Let me see if I have this right... I have to post the form on > SignUp.php back to SignUp.php, perform the validation, and redirect
to
> the confirmation page if everything passes validation prior

to the > <html> tag?
>
> thanks again.


Hi Bob, surprised you get a blank page. Is there a URL or

nothing at
all? Why donít you create a test script with just the

header
statement and see how it works.

Yes, you redirect to the same page. So your form would say
<form action=íí method=post>
and you also would have a hidden field <input type=hidden....
which would be used in the validation to detect that the form has

been
submitted. Then if everything is ok, you can redirect.

--
http://www.dbForumz.com/ This article was posted by

authorís request
Articles individually checked for conformance to usenet standards
Topic URL:

http://www.dbForumz.com/PHP-header-r...ict141549.html
Visit Topic URL to contact author (reg. reqíd). Report

abuse:
http://www.dbForumz.com/eform.php?p=473984


Bob, as far as header, try to do the header logic at the very top of
the code before anything else is sent. Also do try the buffering with
ob_start, if nothing else works.

PHP has a nice "include" so you can keep the logic in one place.
That is not a problem. Just be cautious of the ways paths in include
work. A bit counter-intuitive, but you should be ok.

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-header-r...ict141549.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=474163
Jul 17 '05 #7
I noticed that Message-ID: <10*************@corp.supernews.com> from Bob
Garbados contained the following:
Any php script that I put on the server that has an error like a missing
semicolon, I just see a blank page and no error message.


Not good. You need a lot more than that for development work.

Create a page containing
<?php
phpinfo();
?>

and see what level of error reporting is set. You may well have to
include a line to turn error reporting back on. See the manual for
details.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #8
Thanks Geoff. I created the phpinfo() page earlier today as well and
display_errors is 'On', error_reporting is '1'. It's my understanding that
errors should be displayed... am I correct?

I also tried adding the commands ini_set("error_reporting", E_ALL); and
ini_set("display_errors", TRUE); at the top of my php script to no avail.

"Geoff Berrow" <bl******@ckdog.co.uk> wrote in message
news:1a********************************@4ax.com...
I noticed that Message-ID: <10*************@corp.supernews.com> from Bob
Garbados contained the following:
Any php script that I put on the server that has an error like a missing
semicolon, I just see a blank page and no error message.


Not good. You need a lot more than that for development work.

Create a page containing
<?php
phpinfo();
?>

and see what level of error reporting is set. You may well have to
include a line to turn error reporting back on. See the manual for
details.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

Jul 17 '05 #9
My hosting company said that they enabled error logs for php and now the
errors show up. Forgive my ignorance, but how does one enable error logs?
"Bob Garbados" <bo*********@hotmail.com> wrote in message
news:10*************@corp.supernews.com...
Thanks Geoff. I created the phpinfo() page earlier today as well and
display_errors is 'On', error_reporting is '1'. It's my understanding that errors should be displayed... am I correct?

I also tried adding the commands ini_set("error_reporting", E_ALL); and
ini_set("display_errors", TRUE); at the top of my php script to no avail.

"Geoff Berrow" <bl******@ckdog.co.uk> wrote in message
news:1a********************************@4ax.com...
I noticed that Message-ID: <10*************@corp.supernews.com> from Bob
Garbados contained the following:
Any php script that I put on the server that has an error like a missingsemicolon, I just see a blank page and no error message.


Not good. You need a lot more than that for development work.

Create a page containing
<?php
phpinfo();
?>

and see what level of error reporting is set. You may well have to
include a line to turn error reporting back on. See the manual for
details.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/


Jul 17 '05 #10
I noticed that Message-ID: <10*************@corp.supernews.com> from Bob
Garbados contained the following:
Thanks Geoff. I created the phpinfo() page earlier today as well and
display_errors is 'On', error_reporting is '1'. It's my understanding that
errors should be displayed... am I correct?

I also tried adding the commands ini_set("error_reporting", E_ALL); and
ini_set("display_errors", TRUE); at the top of my php script to no avail.


Others know more than me but I use
error_reporting(E_ALL);
ini_set('display_errors', 1);

If that doesn't work, I'm stumped.

If you are using Windows you could simply try downloading PHPDEV from
www.firepages.com.au and doing your development on your local machine.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Pete Bennett | last post: by
3 posts views Thread by Greg Scharlemann | last post: by
6 posts views Thread by scottyman | last post: by
5 posts views Thread by Duderino82 | last post: by
8 posts views Thread by php newbie | last post: by
18 posts views Thread by Paul Lautman | last post: by
4 posts views Thread by Call Me Tom | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.