Jump to content

[SOLVED] Post form data multiple places


thenoto

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/116883-solved-post-form-data-multiple-places/
Share on other sites

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.

 

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());
?>

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 protected]&zipcode=12345&phone=123-456-7890");

curl_exec ($ch);
curl_close ($ch); 
?>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.