Forum Moderators: coopster
I have a form to be submited using POST method to a url: http://xx.#*$!.#*$!.xx/bulk/
if the operation is successful, the server responds with :
status=n&credit=mm&recipient=yyyyy&deterer=gggin the body of a page
The issues i have are:
1. how do i save the content of the form elements before posting them to the url
2. on posting the form directly to the url, it returns the response above in the body of a page pointing to the server.
Pls how do i extract the variables i need from the body of the server response page and redirect the response to my own custome page. cos i just need users to be redirected to a custome page showing just the status(i.e n) and credit( i.e mm) and recipients(i.e yyyyy)from the server.
Pls any help will be appreciated as i have tried several stuffs and read various articles from google and have not being able to achieve my objectives
$ch = curl_init();
$data = array(
'name' => $_POST['name'],
'email' => $_POST['email'],
// etc. you get the idea ;)
);
curl_setopt($ch, CURLOPT_URL, 'http://remotehost/form.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$return = curl_exec($ch);
if($return === false){
echo 'Sorry! It didn\'t work.';
} else {
$result = parse_str($return);
print_r($result); // for debugging
echo 'Your status is '.$result['status'].' and your credit is '.$result['credit'].'.';
}