Link to home
Start Free TrialLog in
Avatar of Tony O'Byrne
Tony O'ByrneFlag for United States of America

asked on

PHP auto-fil and auto-submit html form

I've got a weird idea here and was wondering how to go about it.  (I have no idea as to where to start.)

I've got a web-form that enters data into a mysql database when the user submits.  I would like to program a php script to automagically fill in the info *and* submit it so that I can automate a whole bunch of entries (1000 for example) so I can have a ton of random sample data to work with for some other scripts that will pull this data and possibly try to trend it.

Just so we're 100% clear, I know I can do it from the shell easy enough, but the thought struck me "I wonder if I could do it this other way?"  So this is more of a curiosity than anything.
Avatar of Tony O'Byrne
Tony O'Byrne
Flag of United States of America image

ASKER

Just to elaborate a little...  When I said that I know it could be done from the shell easy enough, I meant that I could do php/mysql via the shell.  What I'm really curious about is php actually sending the information and submitting it as if the user had done it.  I guess I would be trying to get php to send a "post" request to the server?

As I said, I've no idea where to start and my above terminology may be ... terminal.  Terminal terminology. :-)
Yes, you can post information to a script.  I use fsockopen() to do that.  I will post an example here for you in a moment. ~Ray
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here is the "catcher" script.
<?php // RAY_dump_superglobals.php
error_reporting(E_ALL);
 
// OPEN AN OUTPUT BUFFER
ob_start();
 
// SHOW THE SUPERGLOBALS
echo "\nGET ";   var_dump($_GET);
echo "\nPOST ";  var_dump($_POST);
echo "\nCOOKIE ";var_dump($_COOKIE);
 
// CAPTURE THE BUFFER
$vardump = ob_get_clean();
 
// SEND THE RESULTS
mail('you@your.org', 'VARDUMP', "$vardump");
 
// SHOW THE RESULTS
echo htmlentities($vardump);
?>

Open in new window

What's the "catcher" script for?
Looks like this'll do. :-)  It gives me something to work off of which is what I was looking for.  If I have any further issues, I'll create a new thread.  Thanks for the help.
The catcher script will receive the POST data and print it out for you.

Thanks for the points - it's a great question, ~Ray