I want to submit a form immediately when a PHP file is visited in the browser. How can I do this: Preferably in jQuery.
Details:
I have a form that once submitted inserts some data into a database and sends the user to a separate page. On the separate page, I have code for another form that then directs users to pay for whatever they have selected.
I don't want the user to have to click submit on the second form in order for them to pay. So is there a way to make that form submit automatically and thus direct the user to the payment stage?
Invoke the submit
method:
$("#formID").submit();
So, at your second page:
<script>
$(function(){
$("#your-formID").submit();
});
</script>
Why does that form exist if it is submitted automatically? Make the first form redirect directly to the third page and handle the rest on the server. No need to send the data to the client if it is not used there. And automatically posting using Javascript may not work on each client. Eliminate the risk by doing it server side.
you can do this
<body onload="submitForm()" ></body>
<script>
function submitForm()
{
document.frm.submit();
}
</script>
frm is name of form