Success page after registration
I don't know what's the good approach for this. I have a registration form that would be sent to a php data handler if the submit button is set and if it contains an error it would be redirect back to the registration form using header function. I would like to show a success page that tells the user that the registration is successful. My code for the data handler looks like this.
if(isset(submit))
{
//input validation
if(error found)
{
//redirect back to the reg form with error msgs
开发者_如何学Go}
else
{
//register user to database
}
}
Do I need to make a dedicated page for success message? It looks ugly if I make the success message to the top of the registration form. I'm using session btw.
Have you considered just using a javascript pop up saying it is successful? You could also consider using some css to style it--maybe have a green background with a green border with a picture of a big green check or something like that.
Yes creating a Success page is a good idea. It provides good feedback that the registration was successful. You can also add a welcome message and some any information the user might need.
For registration and other form submission pages, the problem is not the direct accessing of the success page. The success page can check for any session variable and redirect if it doesn't exist. Or it can just display the success message again. Why not?
The real problem is that you don't want to post the form data twice, which can happen if you don't have any redirect inbetween. If the result page shows up after the post, and the user refreshes the page, the data gets posted again.
To work around this, one has invented the Post/Redirect/Get pattern. It basically states that you post the data to one url, and put a redirect in the response. The redirect goes to a success page, which gets any information (by passing an id in the url, or by just reading the session, but without any post data anyway). That way, the posted page doesn't show up in the history. When the user posts the form, he will go back to the moment before the form was posted, not to the post action itself.
精彩评论