Hi,
I’d like to create a newsletter sign up form on my website, that records the email on the my site cs-cart shop db.
Is it possible? And how?
Thanks
If it is not on one server then you can do it with PHP with small “web applications.”
Your website would add new emails to a text file one after another, then with chron run a PHP file that connects to a PHP file on shop end. Post in https a special password in a variable and all the emails. On shop end you would receive new emails as array, insert them into DB, send OK flag back so your website could delete the text file with emails.
I update this way new orders with UPS tracking numbers, automatically, once a day our servers talk, negotiate, transfer info, leave some log.
You use curl on one end to post, regular $_POST on the other to filter the info. Then echo status, the curl will return with the echoed text and you can “switch” the status…
This with type=1 and password 1234a connects to my webapp and gets some data.
```php
function get_data(){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,‘https://site.com/myapp.php’);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,‘pass=1234a&type=1’);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$out=curl_exec($ch);
unset($ch);
return (string)$out;
}
```
This data gets processed and then I POST accordingly later.
```php
function post_data($arr){
$temp=serialize($arr);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,‘https://site.com/myapp.php’);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,‘pass=1234a&type=2&data=’.urlencode($temp));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$out=curl_exec($ch);
unset($ch);
return (string)$out;
}
```
The shop site would have this:
```php
if(!isset($_SERVER[‘HTTPS’])) exit(‘no https’);
if($_SERVER[‘HTTPS’]!=‘on’) exit(‘no https’);
if($_SERVER[‘REQUEST_METHOD’]!=‘POST’) exit(‘no data’);
if(!isset($_POST[‘pass’])) exit(‘bad pass’);
if($_POST[‘pass’]!==‘1234a’) exit(‘bad pass’);
if(!isset($_POST[‘type’])) exit(‘unset mode’);
if($_POST[‘type’]!=1 && $_POST[‘type’]!=2) exit(‘bad mode’);
//----------------LOAD CS CART
define(‘AREA’, ‘C’);
define(‘AREA_NAME’ ,‘customer’);
require dirname(FILE) . ‘/prepare.php’;
require dirname(FILE) . ‘/init.php’;
//----------------
if($_POST[‘type’]==1){
//get data and echo it like:
echo serialize($arr);
}
elseif($_POST[‘type’]==2){
//here you can filter $_POST and echo status codes based on received input
echo ‘Error: Bad format’; //and etc
//at the end you can echo ‘OK’ and if on the other end OK not received, then it must be an error…
echo ‘OK’;
exit();
}
```