Online Shopping : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

21 of 40 people (53%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

Can PHP automate Form entries and retrieve the resulting data (as if someone pressed "submit")?

Mar 15th, 2008 18:12
ha mo, Scott Noyes, Vip Malixi,


PHP is server side.  Forms appear in the browser, which is client side.
 PHP can fill out the form if the information is known, by adding the
'value' attribute to the form.  PHP can generate a client-side script
such as JavaScript to submit the form, but it cannot trigger a form
submission on its own.
Example:
<?php
$userName = 'JoeQ';
$password = 'mySecurePassword';
echo <<<HTML
<body onLoad='document.theForm.submit()'>
  <form name='theForm' action='somePage.php'>
    <input type='text' name='username' value='$userName'>
    <input type='password' name='password' value='$password'>
    <input type='submit' name='submit' value='Submit'>
  </form>
</body>
HTML;
?>
http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.mozmar.com
http://www.yamot.com
http://www.templatestemp.com