Mon Oct 27, 2008 11:52 pm
<?php
class InvalidEmailException extends Exception {
function __construct($message, $email) {
$this->message = $message;
$this->notifyAdmin($email);
}
private function notifyAdmin($email) {
mail("[email protected]","INVALID EMAIL",$email,"From:[email protected]");
}
}
class subscribe {
function validateEmail($email) {
try {
if ($email == "") {
throw new Exception("You must enter an e-mail address!");
} else {
list($user,$domain) = explode("@", $email);
if (! checkdnsrr($domain, "MX")) {
throw new InvalidEmailException("Invalid e-mail address!", $email);
} else {
return 1;
}
}
} catch (Exception $e) {
echo $e->getMessage();
} catch (InvalidEmailException $e) {
echo $e->getMessage();
}
}
function subscribeUser() {
echo $this->email." added to the database!";
}
}
$_POST['email'] = "[email protected]";
if (isset($_POST['email'])) {
$subscribe = new subscribe();
if($subscribe->validateEmail($_POST['email']))
$subscribe->subscribeUser($_POST['email']);
}
?>
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.