My Question is, i want the second server (file2.php) to send the first server (file1.php) the $error message:
Case 1: email was inserted successfully
Case 2: query could not be excuted
Case 3: Duplicate found
Not sure I understand the relationship between these two files.
Since the curl code is literally all hard coded from what is in file1, you can simply include it as necessary into file2, and it will have direct access to the $error variable to do with whatever you have to do. Otherwise, you can put it with file_get_contents and provide it with an http wrapper and a querystring with the $error, or even use curl once again to connect to file1.php. I'd opt for the include myself.
Basically, we have provided our client file1.php to be located into their server and file2.php is located on our server, every time the clients add an email to their database, file1.php is executed and the email is send to us, our database must also include a copy of the email.
We are looking for a solution!! Client server must send us the email and we must send them back the response.
So why are you using cURL to post to postme.php instead of file2.php?
Am I missing something? ???
As for the result of your call to file2.php OR postme.php, it should be contained in the $result variable from file1.php.. if I'm understanding your code and principle correctly and seeing as you're referring to file2.php and postme.php I'm not entirely sure I am.
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
So why are you using cURL to post to postme.php instead of file2.php?
Am I missing something? ???
As for the result of your call to file2.php OR postme.php, it should be contained in the $result variable from file1.php.. if I'm understanding your code and principle correctly and seeing as you're referring to file2.php and postme.php I'm not entirely sure I am.
Confused? Imagine how I feel!
Sorry I just forgot to rename “postme.php” to “file2.php” on this thread, the script is working fine, file2.php is receiving the email and is being inserted into our database, and the problem comes with the response messages.
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
I think I see what you are doing here.
Add a return transfer for the curlopt: curl_setopt(CURLOPT_RETURNTRANSFER, 1);. Now this file will be able to pull the results of the curl_exec call and store it in a variable.
Then with the script its connecting to, just output what is required. If this is exactly what the second script uses, I'd actually return the results as integers and handle it in the receiving file1 script. So on success, print 0, failure print 1. And for a sql error such as a duplicate, I'd push something different.
Now, this is if you want to use curl. This is actually a perfect example of the use of soap services. It takes some work to set up soap server and client's properly, but when you do they sure become easy. What happens here is the client file1 would establish a soap client connection to the remote server. The remote server would present it with a method called say, insertEmailAddress. This method is called much like a regular PHP function, and the results can be captured as a part of the soap protocols for returning. Super easy to use. Soap is somewhat tough to set up on PHP I find.