I can not figure this out, why is it still inserting into database if I use a yahoo email or hotmail.
It should not insert into DB if a person uses yahoo email or hotmail.
Otherwise it works like it should.
Do I have somethng not in order or am i missing something ?
Please help if you can..
function validateEmail($fEmail, $fBannedHosts)
{
// use regex to see if email follows pattern: <name>@<domain>.<suffix>
if(!eregi("^([_a-z0-9-]+)(.[_a-z0-9-]+)*@([a-z0-9-]+)(.[a-z0-9-]+)*(.[a-z]{2,4})$", $fEmail))
{
// if not die w/ error
//die("<b>Error: </b> You entered an invalid email address!");
die("<center>Error : Incorrect email <a href=\"../submit.php\">Go Back</a></center>");
}
// if $fBannedHosts is set to free use these hosts
if($fBannedHosts == "free")
{
$fBannedHosts = array("hotmail.com",
"yahoo.com",
);
}
// split up the email addy into two variables
list($fUser, $fDomain) = split("@", $fEmail);
// go through all of the banned hosts
foreach($fBannedHosts as $fBannedHosts)
{
// check to see if users host is a banned host
if($fDomain == $fBannedHosts)
{
// if it is die w/ error
//die("<b>Error: </b> Your email host(". $fDomain .") is not allowed by this site!");
echo "<center>Error : Your email host(". $fDomain .") is not allowed by this site <a href=\"../submit.php\">Go Back</a></center>";
}
}
}
function mailPoster($email,$subj,$ADM_MAIL,$msgHTML,$msgTEXT) {
// headers need to be in the correct order...
$headers = "From: \"<$ADM_MAIL>\" <$ADM_MAIL>\n";
$headers .= "MIME-Version: 1.0\n";
// the following must be one line (post width too small)
$headers .= "Content-Type: multipart/alternative;\n boundary=\"NextPart_534543534534534534\"\n";
$headers .= "X-Sender: $ADM_MAIL<$ADM_MAIL>\n";
$headers .= "X-Mailer: CBN Post Mailer\n"; //mailer
$headers .= "X-Priority: 2\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: $ADM_MAIL\n";
$headers .= "This is a multi-part message in MIME format.\n";
//plaintext section begins
$msg = "--NextPart_534543534534534534\n";
$msg .= "Content-Type: text/plain; charset=windows-1252\n";
//$msg .= "Content-Transfer-Encoding: quoted-printable\n";
$msg .= "\n";
// your text goes here
$msg .= $msgTEXT."\n";
//$msg .= "\n";
// html section begins
$msg .= "--NextPart_534543534534534534\n";
$msg .= "Content-Type: text/html; charset=windows-1252\n";
$msg .= "\n";
// your html goes here -- It didn't appear properly without
// the weird markup that outlook added after sending
//$msg .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
$msg .= $msgHTML."\n\n";
// this ends the message part
$msg .= "--NextPart_534543534534534534--\n";
$msg .= "\n";
// send the message :-)
//$banned = array("banned.com","aol.com");
//validateEmail("email@email.com", $banned);
validateEmail("$email", "free");
mail($email, $subj, $msg, $headers);
};
switch ($cmd) {
case "add":
//Auto Submit below
$title = str_replace(",","",$title);
$email = str_replace(",","",$email);
$url = str_replace(",","",$url);
$title = htmlspecialchars($title);
$putAd = q("insert into links values ('','$email','$title','$url','1','1')");
mailPoster($email,$curSubject[0],$ADMIN_EMAIL[0],$curMessage[0],$curTextMsg[0]);
//header ("Location: ../success.php");
Break;
//Manual Submit below
case "autoadd":
$title = str_replace(",","",$title);
$email = str_replace(",","",$email);
$url = str_replace(",","",$url);
$title = htmlspecialchars($title);
$putAd = q("insert into links values ('','$email','$title','$url','1','2')");
mailPoster($email,$curSubject[0],$ADMIN_EMAIL[0],$curMessage[0],$curTextMsg[0]);
header ("Location: ../success.php");
Break;
};