insert newsletter form in database
This commit is contained in:
parent
b5a0a49998
commit
63cd5cd605
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/config/PRIVATE/*
|
||||
!/config/PRIVATE/*.example
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
$_ENV['newsletter_url_fr'] ='';
|
||||
$_ENV['newsletter_url_en'] ='';
|
||||
|
||||
?>
|
@ -1,22 +1,15 @@
|
||||
<?php
|
||||
require_once $_SERVER['DOCUMENT_ROOT'].'/config/PRIVATE/NEWSLETTER.php';
|
||||
require_once $_SERVER['DOCUMENT_ROOT'].'/config/PRIVATE/DB.php';
|
||||
$lang_folder = $_GET['newsletter-language']=="fr"?"/pages/fr/":"/pages/en/";
|
||||
$contact_form_url = $_GET['newsletter-language']=="fr"?$_ENV['newsletter_url_fr']:$_ENV['newsletter_url_en'];
|
||||
|
||||
if(!str_contains($_GET['newsletter-email'], "@") || !str_contains($_GET['newsletter-email'], ".") || strlen($_GET['newsletter-email']) < 6 || $_GET['newsletter-email-2'] != "") {
|
||||
if(!filter_var($_GET['newsletter-email'], FILTER_VALIDATE_EMAIL) || $_GET['newsletter-email-2'] != "") {
|
||||
header('Location: '.$lang_folder.'err/general.html');
|
||||
die();
|
||||
}
|
||||
$ch = curl_init($contact_form_url);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, urlencode('email').'='.urlencode($_GET['newsletter-email']));
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
|
||||
curl_exec($ch);
|
||||
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
if($httpcode==200){
|
||||
|
||||
$insert_email = $pdo->prepare('INSERT IGNORE INTO newsletter(email,language) VALUES (?,?)');
|
||||
$insert_email->execute(array($_GET['newsletter-email'],$_GET['newsletter-language']));
|
||||
if($insert_email->rowCount()==1){
|
||||
header('Location: '.$lang_folder.'confirmation.html');
|
||||
die();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user