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
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.

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.