Hi Guys,
I've been wrestling with this for a while but I can't figure out what's wrong with it.
I am trying to send details through a form, this info is sent to a second page which combines that data with data from a database and the page is autosubmitted to a processing script. The problem is, when the user clicks the back button on the last page they are taken to the second page and the details are resent. I need to delete the second page from the browsers history so they can't go back to it.
I've used a previous thread from experts-exchange.com for the solution, but it didn't work -
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20282674.htmlI've used this script, but when the form on my page is automatically submitted, the action of the form doesn't seem to work - the next page is '/undefined' e.g.
www.myurl.com/undefined.
I've knocked up a quick example to show you what is happening in the most simple form.
http://www.bigwebhost.net/ee_examples/firstpage.htmWhen you visit this page, click the send button and it takes you to the second page which includes the script as shown below;
<script language="javascript">
function firstrun()
{
document.forms[0].submit()
;
location.replace(this.href
);
return false;
}
</script>
########### in the body tag ################
<body onload = "firstrun()">
##########################
########
I have disabled the onload function on this page -
http://www.bigwebhost.net/ee_examples/secondpage_code.php to show you the code that is on the second page.
it auto submits the form but the action of the form doesn't seem to work. The back button problem is solved but the details aren't sent through to the script.
I hope all of this is clear, if not I can explain further. Also, please don't provide any solutions in PHP, the pages will eventually be uploaded to an ASP server so if you could provide the solution in Javascript that would be a great help.
Thank you.
Elliott.
View the Solution FREE for 30 Days