Online Shopping : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to
Did You Find This Entry Useful?

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


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.
$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'>