Form & Thank-you on same page!
I was asked recently how I have a feedback form on my page that when submitted leads a thank-you message on the same page. This guide shows you how to do this simple but effective query string "trick" which has multiple applications.
How this works is we set a query string to a particular "keyword" then when the page loads the SSI reads the "keyword" and displays the content specified for that keyword.
I'll break it down into steps with an example to explain it better.
Form and Thank-you page
We have a basic HTML form submitting whatever information you require located on contact.shtml. We use a hidden input tag to specify the redirect to the thank you page after form submittal. The "thank-you" page should also be contact.shtml but we add a query string containing our "keyword":
<input type="hidden" name="redirect" value="contact.shtml?submitted">
The SSI then reads this query string and IF the query string IS submitted it will display your thank-you message. (If you check your browser address bar you would see http://domain.com/contact.shtml?submitted) Check this example:
IF Query String IS submitted
The correct syntax for this example would be (remember the form is in contact.shtml) :
<!--#if expr="$QUERY_STRING = 'submitted'"
You can add any number of "steps" in this process once you get the code right. At the time of writing this I use two steps as shown below for a site feedback form:
<!--#if expr="$QUERY_STRING = 'submitted2'"
It's not entirely practical that you receive 2 form submissions but it still has many obvious uses. Be imaginative!