Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 6 years ago.
I have a PHP page with an HTML form on it. If some variables are set in the URL I would like to automatically submit the form on the page.
IE:
if (isset($_GET['var']))
{
// SUBMIT FORM
}
else
{
// leave the page alone
}
EDIT:
Here is what I have using the answer that someone provided below, but it's still not working. I would like the form to submit itself if the condition is met.
<?php
if ($r == 1)
{
echo "
<br>
<form action=\"bookRoom.php\" method=\"post\" id=\"dateForm\">
<input name=\"from\" type=\"hidden\" value=\"$fday/$fmonth/$fyear\">
<input name=\"to\" type=\"hidden\" value=\"$tday/$tmonth/$tyear\">
<input type=\"submit\">
</form>
<script type=\"text/javascript\">
$('#dateForm').submit();
</script>
";
}
?>