-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnewsletter.php
33 lines (29 loc) · 1.18 KB
/
newsletter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
if(isset($_POST['submitNewsletter'])){
// Include the database configuration file
include_once 'db.php';
$name = $_POST['name'];
$email = $_POST['email'];
// echo $name;
// echo $email;
$statusMsg = $errorMsg = $insertValuesSQL = $errorUpload = $errorUploadType = '';
$insertValuesSQL .= "('".$name."','".$email."'),";
if(!empty($insertValuesSQL)){
$insertValuesSQL = trim($insertValuesSQL, ',');
// Insert image file name into database
$insert = $conn->query("INSERT INTO subscriber (`name`, `email`) VALUES $insertValuesSQL");
if($insert){
$errorUpload = !empty($errorUpload)?'Upload Error: '.trim($errorUpload, ' | '):'';
$errorUploadType = !empty($errorUploadType)?'File Type Error: '.trim($errorUploadType, ' | '):'';
$errorMsg = !empty($errorUpload)?'<br/>'.$errorUpload.'<br/>'.$errorUploadType:'<br/>'.$errorUploadType;
$statusMsg = "Subscribed successfully.".$errorMsg;
}else{
$statusMsg = "Sorry, there was an error uploading your file.";
}
}
echo $statusMsg;
}
else {
echo "is not set";
}
?>