I have a contact form on my site. It can either use PHP script to capture data and email it to me, or send it to API directly, by changing <form action="">
By API i mean a script that captures info and saves it to external DB. The API is based on ASP (this is my presumption), and I have no access to it, and have to use the format specified below.
I need to modify the PHP script, so it send info by email AND to the external API using this SPECIFIC format using POST method.
Disclaimer: I'm not a programmer, but I can figure our how to do things, if pointed in the right direction.
The format in wich API accepts info:
<form action="https://api.somsite.com/?user=&key=&zipcode=&name=&phone=&email=&address=&service=" method="post">
<input type="hidden" name="user" value="12345"/>
<input type="hidden" name="key" value="0987654321"/>
Hidden values (USER and KEY) are used so API knows where info came from.
Other inputs are provided by user (Name, Email, Zip, Phone, Address, Service).
Here is what my current PHP script looks like:
<?php session_start(); ?><?php
$to = "myemail@gmail.com";
$subject = "LEAD";
$email = $_REQUEST["email"];
$name = $_REQUEST["name"];
$address = $_REQUEST["address"];
$zip = $_REQUEST["zipcode"];
$phone = $_REQUEST["phone"];
$service = $_REQUEST["service"];
$user = $_REQUEST["user"];
$key = $_REQUEST["key"];
$dodgy_strings = array(
"content-type:"
,"mime-version:"
,"multipart/mixed"
,"bcc:"
);
$msg = 'Name: '.$name. PHP_EOL;
$msg .= 'Phone: '.$phone. PHP_EOL;
$msg .= 'E-mail: '.$email. PHP_EOL. PHP_EOL;
$msg .= 'Address: '.$address. PHP_EOL;
$msg .= 'Zip code: '.$zip. PHP_EOL. PHP_EOL;
$msg .= 'Service: '.$service. PHP_EOL. PHP_EOL;
$msg .= 'User ID: '.$user. PHP_EOL. PHP_EOL;
$msg .= 'Access Key: '.$key. PHP_EOL. PHP_EOL;
$msg .= PHP_EOL;
mail($to, $subject, $msg);
header('Location: http://www.mysite.com/thankyou.htm'); // This redirects to Thank You page
?>
Basically, I need to use the above PHP script together with some sort of CURL function, or similar.
I read somewhere on STACK that I would need to us CURL function in PHP, but have no idea how to implement it.
Please help - I would appreciate it VERY VERY much.
Sincerely, Leo.