I'd use the header function to redirect back to the input page, like this:

phpheader('Location: http://www.mydomain.com/form.php');exit;

I'd avoid using the include method as you end up showing the user the same page with two different URLs, it might be a little confusing for the user and it's not ideal from a SEO point of view.

Hi fretburner,

I tried your suggestion and it works the page does go back but there's small problem. when it returns back to the calling script the user entered information is wiped out. I rather not have the user re-enter the information again.. any thoughts on this?

I'd avoid using the include method as you end up showing the user the same page with two different URLs, it might be a little confusing for the user and it's not ideal from a SEO point of view.

In this particular case this is not a problem and the include method (or any other that avoids a redirect) is the best one. The URL of the form page doesn't change depending on whether the form is displayed the first time (when presented empty to the user) or pre-filled after the user submitted incorrect data. Having a separate URL for the empty form and for the pre-filled form is superfluous and search engines will not go the the latter anyway since its accessed by POST and not by a link.

After the user fills in the form correctly and is about to see another page - that is the good moment to use a redirect, because he leaves the form page and goes to another one.

There are two possibilities: he is logged in or not. If logged in he sees the form. If not he sees a form asking him to log in. If he logs in properly he sees the form. If not he gets some feedback. No change in URL.

I usually have a review screen before final submission. This, in fact, is another form with hidden fields and two buttons Edit, Submit, same URL as above.

The form is finally submitted and the user gets some feedback, same URL as above.

Everything that has to do with this form has the same URL. Semantically it makes sense to me. Search engines only see the log in form if a password is required and the suggestion is to exclude them with the robots tag and/or the robots text file.

Lemon Juice, fair point, I usually go with the method described in my second post which is basically what you're recommending.

captainccs said:

I use includes and no redirects and I don't have the two url's per page problem.

The situation described in the OP would result in two URLs with the same content, as it includes the content of the form page on the processing page.

As Lemon Juice points out, it's not always a problem, but there are situations where you might have a form and some other content on the same page (perhaps some detailed instructions, for example) which you don't want to have indexed twice. And even if the form method is POST, the URL of the second page could still be linked to from elsewhere and potentially crawled. It's worth bearing in mind all the angles.

And even if the form method is POST, the URL of the second page could still be linked to from elsewhere and potentially crawled. It's worth bearing in mind all the angles.

I don't understand how you can have a "second page" if you have a single URL and no redirect. I realize you might have different content on the one page depending at what point in the processing it's at.

Obviously there is more code containing if statements and such, but I think it's easily figured out. This is how I go about do this, but I would say there really isn't no 'best' practice in redirecting or returning a calling script. In my opinion it's just how the person likes to code in order to get from point a to point b. Just my .02 cents.