Different requirement for redirecting usersWe redirect the user to different pages or different site based on the condition or based on user selection. We may need different pages to be executed under different conditions. Some time visitor goes to different pages by clicking different links available on the page. But here we will learn how to redirect the user based on our program or our requirement. There can be many reasons to go for a redirection. Here are some of the common reasons for going for a redirection.
Server side form validationWe submit a form with data and we can design a server side form validation to check the user entered data. If the data entered by the user is not in required format or not as per standards then we may ask the visitor to feed the data again. So here we will send back the visitor to the same form page again showing the error message and asking the visitor to try again.
Sending users to different sections based on the permission level
In a portal we may have different areas marked for different types for users and we want the users to go directly to assigned area after they submit their identity ( may be by login ) . Here without any trigger from user end system will redirect the user to a page for there use.
End of a process.Some time after submitting a data or after a forum posting you want the visitor to be redirected to display a Thank You message. We can have a common thank you page or an error page where we can redirect the browser.
We will discuss header redirection here. Read more on the same topic in PHP section header redirection.
Header Redirection precautionOne main care we have to take care before giving any header redirection is no data to be posted to the user browser before the header redirection command is applied. We can do our script processing and before sending any output to the browser we will redirect the user. Sometime we may not have any output intentionally posted before the redirection but under various condition some time error message the script will return, resulting in error message saying header already send.
Here is the common error message given by ASP engine if header is already sent and script example of header redirection using Response object.
This article is written by plus2net.com team.
Be the first to post comment on this article :