Hi guys,
I’m a new poster here and I’m having a bit of trouble validating this form for a client.
They want to make sure that people can’t submit the form without entering a valid email address.
Any help
Thanks in advance.
[CODE]<?php
class AttachMailer{
private $from, $to, $subject, $mess, $hash, $output;
private $documents = Array();
/*
* @params from: adresse de l’envoyeur(+reponse)
* to : adresse a qui on envoie
* subject : le sujet du message
* mess : le message lui meme(format html)
*/
function __construct($_from, $_to, $_subject, $_mess){
$this->from = $_from;
$this->to = $_to;
$this->subject = $_subject;
$this->mess = $_mess;
$this->hash = md5(date(‘r’, time()));
}
/*
* @params url du document ajouté
*/
public function attachFile($url, $name = “”){
$attachment = chunk_split(base64_encode(file_get_contents($url)));
$docName = $name == “” ? basename($url) : $name;
$randomHash = $this->hash;
$docOutput = “–PHP-alt-$randomHash–rnrn”
.”–PHP-mixed-$randomHashrn”
.”Content-Type: application/pdf; name=”$docName” rn”
.”Content-Transfer-Encoding: base64 rn”
.”Content-Disposition: attachment rnrn”
.$attachment . “rn”;
$this->documents[] = $docOutput;
}
private function makeMessage(){
$randomHash = $this->hash;
$messageOutput = “–PHP-mixed-$randomHashrn”
.”Content-Type: multipart/alternative; boundary=PHP-alt-$randomHashrnrn”
.”–PHP-alt-$randomHashrn”
.”Content-Type: text/plain; charset=’iso-8859-1’rn”
.”Content-Transfer-Encoding: 7bitrnrn”
.$this->mess . “rnrn”
.”–PHP-alt-$randomHashrn”
.”Content-Type: text/html; charset=’iso-8859-1’rn”
.”Content-Transfer-Encoding: 7bitrnrn”
. $this->mess . “rn”;
foreach($this->documents as $document){
$messageOutput .= $document;
}
$this->output = $messageOutput;
}
public function getSignupTime(){
return date(‘d F Y H:i:s’, time());
}
public function send(){
$this->makeMessage();
$from = $this->from;
$randomHash = $this->hash;
$headers = “From: $fromrnReply-To: $from”;
$headers .= “rnContent-Type: multipart/mixed; boundary=”PHP-mixed-$randomHash””;
$mail_sent = @mail( $this->to, $this->subject, $this->output, $headers );
return $mail_sent ? true : false;
}
}
// Receiving variables
@$signup_time = “”;
@$pfw_ip= $_SERVER[‘REMOTE_ADDR’];
@$email_address = addslashes($_POST[’email_address’]);
@$first_name = addslashes($_POST[‘first_name’]);
@$last_name = addslashes($_POST[‘last_name’]);
@$adr_1 = addslashes($_POST[‘adr_1’]);
@$city = addslashes($_POST[‘city’]);
@$state = addslashes($_POST[‘state’]);
@$province = addslashes($_POST[‘province’]);
@$country = addslashes($_POST[‘country’]);
@$postal_code = addslashes($_POST[‘postal_code’]);
@$dob_month = addslashes($_POST[‘dob_month’]);
@$dob_day = addslashes($_POST[‘dob_day’]);
@$dob_year = addslashes($_POST[‘dob_year’]);
@$flash_mob = addslashes($_POST[‘flash_mob’]);
//Don’t print flash_mob region if it’s the default
if ($flash_mob == “I live near…”)
{
$flash_mob = “Not Selected”;
}
//Send an auto email to the subscriber
$mailer = new AttachMailer(“info@xxxxxxxxxxxxx”, “$email_address”, “Your eBook from The Website is Here!”,
“<div style=’font-family: Arial; font-size: 12px; width: 700px;’>
<p>Thanks so much for joining my fan club! (:</p>
<p>If you’d like to connect with me, find me on one of my social media pages.<br />Here’s my info:</p>
<p><br />
Twitter: <a href=’http://twitter.com/@xxxxxxxxxxxxx’>http://twitter.com/@xxxxxxxxxxxxx</a><br />
Tumblr: <a href=’http://xxxxxxx.tumblr.com/’>http://xxxxxxxxxxxx.tumblr.com</a><br />
Facebook: <a href=’http://www.facebook.com/xxxxxxx’>http://www.facebook.com/Bxxxxxxxxxxx</a><br />
YouTube: <a href=’http://www.youtube.com/user/xxxxxxxxxx’>http://www.youtube.com/user/xxxxxxxxxxxx</a><br />
Taringa: <a href=’http://www.taringa.net/perfil/xxxxxxxxxxxxx’>http://www.taringa.net/perfil/xxxxxxxxxxxxx</a>
</p><br />
<p>(: NAME</p>
</div>”);
$mailer->attachFile(“http://www.xxxxxxxxxxxxx/xxxxxxxxxxxxx/wp-content/themes/xxxxxxxxxxxx/downloads/ebook.pdf”);
$mailer->send() ? “sent”: “problem sending”;
//Send an auto respond Email to site admin
$mailer = new AttachMailer(“info@xxxxxxxxxxxxx”, “info@xxxxxxxxxxxxx”, “$first_name $last_name signed up for the Fan Club!”, “<div style=’font-family: Arial; font-size: 12px; width: 700px;’>
<p>A new user signed up for the fan club!</p>
<p>
Name: $first_name $last_name<br />
Email: $email_address<br />
Address 1: $adr_1<br />
City: $city<br />
State: $state<br />
Country: $country<br />
Province: $province<br />
Zip: $postal_code<br />
DOB: $dob_month-$dob_day-$dob_year
Flash Mob Region: $flash_mob
</p>
<br />
<p>This information has been captured in a CSV file on the server for your records.</p>
</div>”);
$mailer->send() ? “sent”: “problem sending”;
//Save record to file
$pfw_file_name = “fanclub.csv”;
$signup_time=$mailer->getSignupTime();
$pfw_first_raw = “signup_time,email_address,first_name,last_name,adr_1,province,city,state,country,flash_mob,postal_code,dob_month,dob_day,dob_yearrn”;
$pfw_values = “$signup_time,$email_address,$first_name,$last_name,$adr_1,$province,$city,$state,$country,$flash_mob,$postal_code,$dob_month,$dob_day,$dob_yearrn”;
$pfw_is_first_row = false;
if(!file_exists($pfw_file_name))
{
$pfw_is_first_row = true ;
}
if (!$pfw_handle = fopen($pfw_file_name, ‘a+’)) {
die(“Cannot open file ($pfw_file_name)”);
exit;
}
if ($pfw_is_first_row)
{
if (fwrite($pfw_handle, $pfw_first_raw ) === FALSE) {
die(“Cannot write to file ($pfw_file_name)”);
exit;
}
}
if (fwrite($pfw_handle, $pfw_values) === FALSE) {
die(“Cannot write to file ($pfw_file_name)”);
exit;
}
fclose($pfw_handle);
header(“Location: http://www.xxxxxxxxxxxxx/xxxxxxxxxxxxx/fan-club-thank-you/”);
?>