thenoto Posted July 27, 2008 Share Posted July 27, 2008 Here is what I am trying to do: 1) User fills out form on mysite.com 2) Data is posted to mysite.com/thanks.php 3) Data is also posted to differentsite.com/thanks.php 4) User stays on mysite.com/thanks.php I tried to do this with curl but it keep redirecting the user to differentsite.com. Quote Link to comment https://forums.phpfreaks.com/topic/116883-solved-post-form-data-multiple-places/ Share on other sites More sharing options...
Attila Posted July 27, 2008 Share Posted July 27, 2008 This can be done in multiple ways it would be nice to see the coding you are using and what exactly you are posting it to a file or a database? Quote Link to comment https://forums.phpfreaks.com/topic/116883-solved-post-form-data-multiple-places/#findComment-601045 Share on other sites More sharing options...
thenoto Posted July 27, 2008 Author Share Posted July 27, 2008 thanks.php is inserting the data into a mysql db. It is a simple lead form containing name, address, email, etc. Quote Link to comment https://forums.phpfreaks.com/topic/116883-solved-post-form-data-multiple-places/#findComment-601046 Share on other sites More sharing options...
Attila Posted July 27, 2008 Share Posted July 27, 2008 Just make the information that is posting to mysite.com/thanks.php and differentsite.com/thanks.php a function then you can just redirect the customer to your mysite.com/thanks.php page. It's the best I can tell you without seing your coding I can't see what might be causing the problem. Quote Link to comment https://forums.phpfreaks.com/topic/116883-solved-post-form-data-multiple-places/#findComment-601048 Share on other sites More sharing options...
thenoto Posted July 27, 2008 Author Share Posted July 27, 2008 I am just posting the data to thanks.php via http and then inserting the data into mysql there. Do you have an example function for the php post? Quote Link to comment https://forums.phpfreaks.com/topic/116883-solved-post-form-data-multiple-places/#findComment-601050 Share on other sites More sharing options...
Attila Posted July 27, 2008 Share Posted July 27, 2008 Here you go this should get you started.: <? function database_connect() { $dbhost = "blabla"; // Database host $dbname = "blablan"; // Database name $dbusername = "blabla"; // Database user name $dbuserpw = "blabla"; // Database password mysql_pconnect($dbhost, $dbusername, $dbuserpw); //Connects to the mysql database area $result = mysql_select_db($dbname); //Connects to the specific database and saves the result as result. if (!$result) return false; //Connected else return true; //not connected } ?> You should have a form that post to itself and checks to make sure everything is entered and you can search these forums for today I have already posted that for someone else. <? //insert the new customer into the database $query = mysql_query("INSERT INTO members VALUES ('', '$name', '$address', '$email')") or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/116883-solved-post-form-data-multiple-places/#findComment-601058 Share on other sites More sharing options...
thenoto Posted July 27, 2008 Author Share Posted July 27, 2008 Thank you for the code. I still need to know how to post the data to differentsite.com without redirecting there. Quote Link to comment https://forums.phpfreaks.com/topic/116883-solved-post-form-data-multiple-places/#findComment-601063 Share on other sites More sharing options...
GingerRobot Posted July 27, 2008 Share Posted July 27, 2008 cURL is the way to go. Did you remember to set CURLOPT_RETURNTRANSFER to true? Quote Link to comment https://forums.phpfreaks.com/topic/116883-solved-post-form-data-multiple-places/#findComment-601106 Share on other sites More sharing options...
thenoto Posted July 27, 2008 Author Share Posted July 27, 2008 No, I didn't. My code is below, where would I add that? <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"http://www.mywebsite.com/thanks.php"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "fname=Test&lname=Lead&email=test@hotmail.com&zipcode=12345&phone=123-456-7890"); curl_exec ($ch); curl_close ($ch); ?> Quote Link to comment https://forums.phpfreaks.com/topic/116883-solved-post-form-data-multiple-places/#findComment-601116 Share on other sites More sharing options...
GingerRobot Posted July 27, 2008 Share Posted July 27, 2008 Add it in with the other options. It doesn't matter on the order: curl_setopt($ch,CURLOPT_RETURNTRANSFRE,TRUE); By default, the reponse to the cURL request will be echoed to the screen. This prevents that. If you do assign the return value of curl_exec() to a variable, the response will be stored there. E.g. $reponse = curl_exec($ch); //check to see if form was submitted successfully. e.g. with regex Incidently, you might also need to set the submit button's value with your request. It is not uncommon for the submission of a form to be detected by checking the submit button has been set. If you don't do this and the site requires it, the form wont get posted. Quote Link to comment https://forums.phpfreaks.com/topic/116883-solved-post-form-data-multiple-places/#findComment-601121 Share on other sites More sharing options...
thenoto Posted July 27, 2008 Author Share Posted July 27, 2008 That did the trick! Thanks GingerRobot! Quote Link to comment https://forums.phpfreaks.com/topic/116883-solved-post-form-data-multiple-places/#findComment-601141 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.