I want to know how can I return to the previous page...
I am on the searched result page where many results are present. For each result, there's an option such as "EMAIL ME".
When a user clicks on it, a thickbox form is opened where a user is required to provide his name & email id. When a user clicks on "send to submit the form," a entry in our database is made and a email is sent to the user via his/her email id.
The problem is, after submitting the form, I want to redirect the user to a searched result page where the user has the option to send an email back.
You could use Ajax for the form submission and then just close the Thickbox. If Ajax is not an option, you could also redirect the user to the previous page by using the referrer URL.
Update:
Since some browsers, sometimes, don't provide a referrer URL, the above would not work. A work around is to have the form in the Thickbox provide the URL of the search page, which could then be used to redirect.
In the Thickbox form, add a hidden element with the URL. This can be done with JavaScript or PHP.
Then instead of using HTTP_REFERER, use the name of the hidden element.
Form:
<input type='hidden' name='searchUrl' value='http://the.search.url' />
PHP:
header("Location: ".$_REQUEST["searchUrl"]);