shriek
shriek

Reputation: 5823

Is there a way to automatically trigger submit without pressing the submit button?

I am trying to submit a form automatically without the need to press the submit button. What I'm trying to achieve is, a page gets the information, processes that information and then redirects it to the other page.

My approach on the redirection so far:-

<form action='<?php echo $url;?>' method='post'>
    <input type='hidden' name='hiddenInfo' value='<?php echo $myInfo;?>'/>
</form>
<?php
header("Location:$url");

I know the above code does not work but I'm just trying to show what my approach is. Is it even possible to automatically submit the data without any event handler.

So far I'm trying to avoid the <meta http-equiv="refresh" content="0;url=http://www.mysite.com/info/"/>.

Thanks in advance.

Upvotes: 1

Views: 7581

Answers (3)

Mohit Dabas
Mohit Dabas

Reputation: 2361

IF you are php programmer then you might not want any javascript answer. the best solution to this is

1.USE A PROXY like paros or HTTP analyser they will give u the insight how site's form is structued

2.notE down the forms POST OR GET VALUE SYNTAX FROM THE HTTP analyzer or paros proxy.

read this tutorial it is the best tutorial out there

http://www.html-form-guide.com/php-form/php-form-submit.html

4.change the content of $_post or $_get according to their structure which you have noted down in

paros or HTTP analyser

Upvotes: 0

Greg
Greg

Reputation: 8784

Couldn't you just use $().submit() on document ready?

$(function() { $("form").submit(); });

or:

$(function() { $("#formid").submit(); });

or:

$(function() { $("form:first").submit(); });

Upvotes: 8

sujal
sujal

Reputation: 1050

<form action='<?php echo $url;?>' method='post' id="myform">
    <input type='hidden' name='hiddenInfo' value='<?php echo $myInfo;?>'/>
</form>
$(function() { $("#myform").submit(); });

Try this, may have more than one form so put some id in that form..

Upvotes: 0

Related Questions