I have some code that gets the user to enter some information and I want that information to be submitted when the page is closed (just to be different) but at the moment, it only gets submitted if you say to stay on the page then exit the page. Thanks in advance
I have 2 files: form.html and and inputs.php
This is the code in "form.html":
<html>
<script>
window.onclose = confirmExit;
window.onbeforeunload = confirmExit;
window.onunload = confirmExit;
function confirmExit() {
document.myform.submit();
return false;
}
</script>
<body>
<form name="myform" action="welcome.php" method="post">
Name: <input type="text" name="name" value="hi"><br> E-mail: <input type="text" name="email" value="test"><br>
<input type="submit">
</form>
<button type="button" onClick="document.myform.submit()">Hello!</button>
</body>
</html>
And this is the code in "inputs.php":
<html>
<body>
Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>
</body>
</html>
Please can only help about the onunload etc be offered and not about any of the other code. Thanks