Note that there are some explanatory texts on larger screens.

plurals
  1. PO1 PHP contact form - 2 Actions - Send info to Email & External API / DB
    text
    copied!<p>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 <code>&lt;form action=""&gt;</code></p> <p>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.</p> <p>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.</p> <p><em>Disclaimer: I'm not a programmer, but I can figure our how to do things, if pointed in the right direction.</em></p> <p>The format in wich API accepts info:</p> <pre><code>&lt;form action="https://api.somsite.com/?user=&amp;key=&amp;zipcode=&amp;name=&amp;phone=&amp;email=&amp;address=&amp;service=" method="post"&gt; &lt;input type="hidden" name="user" value="12345"/&gt; &lt;input type="hidden" name="key" value="0987654321"/&gt; </code></pre> <p>Hidden values (USER and KEY) are used so API knows where info came from.</p> <p>Other inputs are provided by user (Name, Email, Zip, Phone, Address, Service).</p> <p>Here is what my current PHP script looks like:</p> <pre><code>&lt;?php session_start(); ?&gt;&lt;?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 ?&gt; </code></pre> <p><strong>Basically, I need to use the above PHP script together with some sort of CURL function, or similar.</strong> </p> <p>I read somewhere on STACK that I would need to us CURL function in PHP, but have no idea how to implement it. </p> <p>Please help - I would appreciate it VERY VERY much.</p> <p>Sincerely, Leo.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload