Example #1
0
<?php

require_once "db.php";
//be mindful of VARIABLE_SCOPE
require_once "mail.php";
if (isset($_GET['news_subscr'])) {
    if (!empty($_POST['email'])) {
        $mail_check = spamCheck($_POST['email']);
        if ($mail_check == false) {
            echo "3";
        } else {
            $email = cleanInput($_POST['email']);
            $q = mysqli_query($conn, "select email from news_l where email='{$email}'");
            if (mysqli_num_rows($q) > 0) {
                echo "0";
            } else {
                $q = mysqli_query($conn, "insert into news_l (email) values ('{$email}')");
                if ($q) {
                    echo "1";
                    /*$to=$email;
                     	$frm="*****@*****.**";
                     	$sbj="TechShule Newsletter Subscription";
                     	$msg="Thank you for Subscribing to the Best Tech News and Information on Startups across Africa.";
                     	if(sendMsg($to, $frm, $sbj, $msg)){
                     		echo "1";
                     	}*/
                }
            }
        }
    } else {
        echo "2";
Example #2
0
                    //mismatch
                }
            } else {
                echo "4";
                //confirm email
            }
        }
    } else {
        echo "2";
        //missing field
    }
}
//message API
if (isset($_GET['send_msg'])) {
    if (!empty($_POST['frm'])) {
        $mail_check = spamCheck($_POST['frm']);
        if ($mail_check == false) {
            echo "0";
        } else {
            if (!empty($_POST['msg']) && $_POST['msg'] != "Write Message Here..." && preg_match("/^[0-9a-zA-Z]+/", $_POST['msg'])) {
                $to = "*****@*****.**";
                $frm = cleanInput($_POST['frm']);
                $sbj = cleanInput($_POST['sbj']);
                $msg = cleanInput($_POST['msg']);
                sendMsg($to, $frm, $sbj, $msg);
            } else {
                echo "1";
            }
        }
    } else {
        echo "0";