Is it possible to automatically submit a php form

I have a website where I have several php forms that I would like to fill in with auto-generated content (for the purpose of using other content that the user might submit). I would like to write a client side application that allows me to do this.

Is there a way to use webtoolkit, java script, etc.?

Thanks everyone for your help, PHPNoob

+2


a source to share


5 answers


If you are already familiar with php, why not use php on the client side? You can use a Client URL to submit POST data to a web form. Example:



<?php
$ch = curl_init();
$data = array('name' => 'phpnoob', 'address' => 'somewhere');

curl_setopt($ch, CURLOPT_URL, 'http://localhost/url/to/your/php/form.php'); // use the URL that shows up in your <form action="...url..."> tag
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

curl_exec($ch);
?> 

      

+4


a source


It would probably be better, more stable and more efficient to mock the view by sending data directly to your application. PHPUnit is a great unit testing framework .



But yes, one could also write a client side view. You can also write Selenium tests that use JavaScript to interact with your page.

+2


a source


if you name your form with id attribute you can call javascript function

MyForm document .submit () ;.

where myform is the name of this form.

0


a source


You can have an onload event attached to the body element that will automatically submit forms.

<body onload="document.form1.submit();document.form2.submit();">
    <form id="form1" action="url" method="post">

    </form>

    <form id="form2" action="url" method="post">

    </form>
</body>

      

Of course, this will be done better using jQuery or another API.

0


a source


IF you are a php programmer then you may not need to respond to javascript. the best solution for this is

1.USE PROXY, for example paros or HTTP analyzer, will give an idea of ​​the structure of the site

2.do not remove the POST or GET VALUE forms and their SYNTAX from the HTTP parser or paros proxy.

read this tutorial, this is the best tutorial out there

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

4.modify the contents of $ _post or $ _get according to their structure you noted in

paros or HTTP parser

0


a source







All Articles