472,958 Members | 2,552 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

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 9037
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Pete Bennett | last post by:
Folks. I have some PHP code on my site at http://www.london-translations.co.uk/quick-quote.php Which allow people to get quotes for translation work. When the form is submitted control...
3
by: Greg Scharlemann | last post by:
Does the redirect statement: header(Location:"http://www.newpage.com"); need to come before certain statements? I've setup a login page and try to redirect a user once they have logged in...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
5
by: Duderino82 | last post by:
I'm working on a very simple peace of php where basically there is a form and 3 buttoms. One refreshed the page, one posts the form, and another one (since this form contains values of a record)...
8
by: php newbie | last post by:
I have a simple php page in which I use header("Location: http://www.example.com/"); to redirect the user to another php page. The php script works on my local machine but when I upload it to...
5
by: 2291980 | last post by:
Hello can any body tell me the dff between function redirect($url) { echo "<script>"; echo "window.location='".$url."'"; echo "</script>";
0
by: robbiesmith79 | last post by:
Here's a workaround that worked for me on a PC, Safari 3, FF 2, IE 7: Basically, you need an intermediary redirect page with a urlencode'd path. For example: AnyPage.php: $path =...
18
by: Paul Lautman | last post by:
JRough wrote: What do you mean by "redirect the output to Excel"??? Excel isn't a location, it's a spreadsheet program that some (but not all users) will have on their machine. BTW, Location:...
4
by: Call Me Tom | last post by:
I was looking at an application with the following code snippet: ob_start(); session_name('foo'); session_start(); if (!$_SESSION) { header("Location: http://" . $_SERVER . dirname($_SERVER)...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.