Looktrne Posted June 27, 2008 Share Posted June 27, 2008 What should I use if I want to post to a form using a php script for example this is my contact form at abmatch.com http://www.abmatch.com/index.php?page=contact_admin how could I post to the fields and submit this form using a php script on another server? any help or a small example would be great thanks... Paul Link to comment https://forums.phpfreaks.com/topic/112261-posting-a-form-using-curl-or-what/ Share on other sites More sharing options...
br0ken Posted June 28, 2008 Share Posted June 28, 2008 I'm not exactly sure what you mean here. Do you mean how can you retrieve the values once the form has been posted? If so try the following. $name = addslashes(strip_tags($_POST['name'])); $email = addslashes(strip_tags($_POST['email'])); $msg = addslashes(strip_tags($_POST['msg'])); if ($message) { $to = "[email protected]" $subject = "Message From Contact Form"; $message = "Name: $name\nEmail: $email\nMessage:\n$msg\n\nIP Address: ".addslashes(strip_tags($_SERVER["REMOTE_ADDRESS"]))."\n\n"; $headers = "from: [email protected]"; $res = mail($to, $subject, $message, $headers); if ($res){ echo "Message Sent"; } else { echo "Message could not be sent"; } } Link to comment https://forums.phpfreaks.com/topic/112261-posting-a-form-using-curl-or-what/#findComment-576443 Share on other sites More sharing options...
Looktrne Posted June 28, 2008 Author Share Posted June 28, 2008 No I need to write a script on another domain for example... http://peapull.com/contactposter.php I need this php file to connect to http://www.abmatch.com/index.php?page=contact_admin and insert into the form $a="field1"; $b="field2"; $c="field3"; and then post the form... Link to comment https://forums.phpfreaks.com/topic/112261-posting-a-form-using-curl-or-what/#findComment-576473 Share on other sites More sharing options...
br0ken Posted June 28, 2008 Share Posted June 28, 2008 Couldn't you just set the form's action field to the url of the script on the other domain? Link to comment https://forums.phpfreaks.com/topic/112261-posting-a-form-using-curl-or-what/#findComment-576479 Share on other sites More sharing options...
Looktrne Posted June 28, 2008 Author Share Posted June 28, 2008 I need the script to act as a browser pretend I do not have access to abmatch.com and I want to submit name: paul email [email protected] sub: I need to post this message into the contact form at abmatch.com going out from a php file called contactsubmitter.php that resides on peapull.com. Asuming I have no affiliation with abmatch.com Paul Link to comment https://forums.phpfreaks.com/topic/112261-posting-a-form-using-curl-or-what/#findComment-576504 Share on other sites More sharing options...
br0ken Posted June 28, 2008 Share Posted June 28, 2008 You don't need a script to act as a browser. Besides, PHP is server side, not client side so could not do this. To do what you're asking would require some Javascript but in this situation that would be superflous. Let me get this straight... On peapull.com there's a contact form. When a user fills this contact form out and hits submit, you actually want the information to be posted on abmatch.com's contact form? If this is what you require it's as simple as having your form open tag as this: <form name="formName" method="POST" action="http://www.abmatch.com"> I would recommend copying the form name and method from the actual ones on abmatch.com The only down side to this is after the message has been submitted, the user will still be on abmatch.com where as I imagine you might want this whole process to be invisible and to them it seems like they never left peapull? If this is so you need to look into using fsockopen and crafting your own HTTP POST request based on the form information. By doing this after the user has posted the message you are still in control and can request them to a confirmation page on your site. Link to comment https://forums.phpfreaks.com/topic/112261-posting-a-form-using-curl-or-what/#findComment-576645 Share on other sites More sharing options...
br0ken Posted June 28, 2008 Share Posted June 28, 2008 For some reason the 'Modify' link isn't on my above post... Anyway, in the action field above I forgot to specify the actual contact form script so here's the an updated version <form name="formName" method="POST" action="http://www.abmatch.com/contact_form.php"> Link to comment https://forums.phpfreaks.com/topic/112261-posting-a-form-using-curl-or-what/#findComment-576671 Share on other sites More sharing options...
Looktrne Posted June 28, 2008 Author Share Posted June 28, 2008 ok now we are getting a bit closer to what I am looking for.. remember how you helped me pull members from the html page well what I want to do is run a google search for a specific page like for example a site with this copywrite... "Copyright© 2006 Web Scribble Solutions" I then want to record the urls returned from the google search.... I then want to visit each url's contact form and post a message to the contact forms for all sites that popped up in that specific google search... for example name: Paul email: myemail.com message: Your webscribble site has bugs that need repair and some needed modifications. visit my http://webscribble-webdate-support.com or contact me directly for more information Paul I pretty much need to find these sites and post to the contact forms automaticly instead of doing this myself it takes a long time... I will also record the urls so I do not send duplicate emails... so what would be my best options on atempting this... thanks Paul Link to comment https://forums.phpfreaks.com/topic/112261-posting-a-form-using-curl-or-what/#findComment-576970 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.