Hia, I have a form that collects a couple pieces of information including name and email. This form points to a script called collect.php. In it, I generate an email and dynamic url and send it to the new subscriber. What I want to do, is to automatically subscribe this person to my autoresponder as well using a form post (as opposed to email subscription). How can I generate a "post" statement from inside collect.php that will send the subscription data to the autoresponder form? Thanks! Chris
Use javascript if i understood you right. And if you want to everything do "silent" use ajax http://www.google.lt/search?q=ajax+auto+submit+form
Hrmm .. here's maybe a little clarification on what I'm hoping to accomplish I'm a total retard when it comes to programming by the way, which I'm sure is totally obvious from this question and the following example $url2post="http://www.letterlive.com/cgi-bin/arp3/arp3-formcapture.pl?first_name=".$POST['firstname']."&lastname=".$POST['lastname']."&email=".$POST['email']."&id=10" $response = fopen($url2post, "r"); Code (markup): Basically process goes like this: 1. User comes to my landing page, completes a signup form and clicks submit 2. Signup form parses input, generates and send an email to the person. 3. signup form posts information to the autoresponder signup form. 4. User gets "Thank You" page. Thanks all!
You can use cURL to send POST data from your PHP script. Check out the manual page: http://php.net/curl You'll specifically need to use the "CURLOPT_POST" and "CURLOPT_POSTFIELDS" options: http://php.net/curl_setopt If your server doesn't have cURL support, you can do the POST yourself using fwrite().
AJax is best for this type of thing you are looking to do. When a user clicks the submit set up a javascript function to handle the input then to redirect them to the thank you page. The php will be called using a ajax function. If you need help in processing the form or sending the email then ask, but post in the ajax/javascript area for help over the "silent" posting of information to a php file.
Thanks for the help. The only reason I want it to be "silent" is so that the user doesn't have to enter their information twice. I'm not trying to be deceitful in any way. I wonder if it would be easier for me to have the autoresponder somehow code the URL and email it, instead of having the formmail script dynamically print the url and then do the subscribe. I bet I can pass a custom field to the autoresponder (ie, link). Thanks for all the suggestions and help!! Chris
Untested but should work. No need for cURL or Ajax; keeps it simple, uses plain PHP. And it's transparent // Post parameters $url2post = "http://www.letterlive.com"; $req = "?first_name=".$POST['firstname']."&lastname=".$POST['lastname']."&email=".$POST['email']."&id=10"; // Build the headers $header = "POST /cgi-bin/arp3/arp3-formcapture.pl HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; // Connect to server $fp = fsockopen ($url2post, 80, $errno, $errstr, 30); if (!$fp) { // Your optional error handler when the connection fails goes here }else{ // Fire off the post fputs ($fp, $header . $req); // read the response if you want to $res = ''; $headerdone = false; while (!feof($fp)) { $line = @fgets ($fp, 1024); if (strcmp($line, "\r\n") == 0) { // read the header $headerdone = true; }elseif ($headerdone) { $res .= $line; } } // optionally parse the response data $lines = explode("\n", $res); // etc. etc....... } PHP: have fun, your php/perl maestro at turborespond.com
QuattroPorte: Why work with sockets? The php fsocket open methods are slow compared to the cUrl ways of doing it. The reason for the suggestion of AJax is they want the information to be saved without having the user to press the submit button themself. Silently save it without them knowing it is saving what they type. At least that is what I understand they want out of it.
Exodus, What it looks like is: User Fills in form at formA.php User submits form at formA.php Data Sent to collect.php Collect.php Works with data (sends email) Collect.php posts information to formB.php QuattroPorte is on the right track, but doing it using sockets is a bit of overkill. Your just doing what cUrl already does. Granted, cUrl assumes that the server has it installed, but it is less overhead and neater code to use it over sockets. www.php.net/curl Cheers,
If you have cURL installed on your box, fine; no need to reinvent the wheel. On the other hand, the performace hit using sockets vs cURL is minimal at worst and insignificant most of the time in an application such as this. The cUrl library does have problems dealing with certain kinds of servers. No portability issues using the socket approach.