Usually I utilize the CURL scripting using the GET method, passing the data as a string.
Is there a way to POST the data to a URL and still echo the response so I may log it in my database?
Below is my normal curl scripting. I populate the variables: $username, $password, and $email from a form on a previous page. Not too difficult.
However, I'm trying to send
// data to pass
$data = 'username='.$username.
'&password='.$password.
'&email='.$email.
'&orderid='.$orderid;
// create a new cURL resource
$ch = curl_init('https://www.somewhere.com');
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_TIMEOUT, '1800');
// Execute the request.
$data_response = curl_exec($ch);
$succeeded = curl_errno($ch) == 0 ? true : false;
print $data_response;
Now I want to try it with a form in the POST method:
<form id="form1" name="form1" method="post" action="NOT SURE WHAT I DO HERE">
<p><input name="username" type="text" id="username" /></p>
<p><input name="password" type="text" id="password"/></p>
<p><input name="email" type="text" id="email" /></p>
<p><input type="submit" name="Submit" value="Submit" /></p>
</form>
Normally I would point the ACTION to the curl script. But the company I am posting to doesn't accept GET methods, only POST.
I've placed "https://www.somewhere.com" inside the ACTION. And I get the necessary response, but it is posted on "https://www.somewhere.com". How do I echo the response so I can log it in my database? Does the curl scripting need to be modified to accommodate a form?
Any ideas? Am I explaining my issue well enough?