ychousa
asked on
Giving a condition to a PHP formMail script
Hi. I'm really a newbie to PHP. The following is a PHP formMail script that I have. I want to add a codition so that if the state input is "OH" or "MD" or "NY", then the formMail is sent to jane@xxxxx.com.
Please understand that I've never studied PHP, so I need a complete script. :-) Here's is the code. It is written by a Spanish. Thanks in advance.
************************** ********** ********** *****
<?php
//
$verificador=$_POST['verif icador'];
//
if (!$verificador) {
// MENSAJE DE ERROR...
$paginaERROR=$_POST['pagin a_error'];
header("Location: $paginaERROR");
//
} else {
////////////////////////// ////////// ////////// ////////// /////
//
// LISTADO DE VARIABLES POST / GET ...
//
$category=$_POST['category '];
$name=$_POST['name'];
$re_email=$_POST['re_email '];
$company=$_POST['company'] ;
$street=$_POST['street'];
$city=$_POST['city'];
$state=$_POST['state'];
$zip=$_POST['zip'];
$phone=$_POST['phone'];
$fax=$_POST['fax'];
$where=$_POST['where'];
$interest=$_POST['interest '];
$message=$_POST['message'] ;
//
$tema=$_POST['tema'];
$paginaOK=$_POST['pagina_o k'];
$paginaERROR=$_POST['pagin a_error'];
////////////////////////// ////////// ////////// ////////// /////
// FECHA ...
$fecha=date("m-d-Y");
// EMAIL REMITENTE / DESTINATARIO ...
$from = $re_email;
$to="info@xxxxx.com";
// ASUNTO...
$subject = $tema;
//
//
////////////////////////// ////////// ////////// ////////// /////
//
// HTML - BODY ...
//
$salto = "\n";
//
$body="------------------- -------".$ salto.$sal to;
//
$body.="Date: ".$fecha.$salto;
$body.="Category: ".$category.$salto;
$body.="Name: ".$name.$salto;
$body.="E-mail: ".$re_email.$salto;
$body.="Company: ".$company.$salto;
$body.="Street: ".$street.$salto;
$body.="City: ".$city.$salto;
$body.="State: ".$state.$salto;
$body.="Zip: ".$zip.$salto;
$body.="Phone: ".$phone.$salto;
$body.="Fax: ".$fax.$salto;
$body.="Where: ".$where.$salto;
$body.="Interest: ".$interest.$salto;
$body.="Message: ".$message.$salto;
//
$body.="------------------ --------". $salto.$sa lto;
//
// ENCABEZADO / CONTENT ...
//
//
$headers = "From: $from\r\n";
$headers .= "MIME-Version: 1.0\r\n";
//$headers .= "Content-Type: text/html; charset=iso-8859-1;";
//
//$content="<html><head></ head><body >";
$content.= $body;
//$content.="</body></html >";
//
////////////////////////// ////////// ////////// ////////// /////
//
// ENVヘA EL EMAIL...
//
$checkEmail=mail($to, $subject, $content, $headers);
//$to="info@xxxxx.com";
//$checkEmail2=mail($to, $subject, $content, $headers);
//
// VERIFICA EL ENVヘO...
//
//if ($checkEmail && $checkEmail2) {
if ($checkEmail) {
header("Location: $paginaOK");
} else {
header("Location: $paginaERROR");
}
//
// FIN //
//
}
?>
************************** ********** ********** ********** *
Please understand that I've never studied PHP, so I need a complete script. :-) Here's is the code. It is written by a Spanish. Thanks in advance.
**************************
<?php
//
$verificador=$_POST['verif
//
if (!$verificador) {
// MENSAJE DE ERROR...
$paginaERROR=$_POST['pagin
header("Location: $paginaERROR");
//
} else {
//////////////////////////
//
// LISTADO DE VARIABLES POST / GET ...
//
$category=$_POST['category
$name=$_POST['name'];
$re_email=$_POST['re_email
$company=$_POST['company']
$street=$_POST['street'];
$city=$_POST['city'];
$state=$_POST['state'];
$zip=$_POST['zip'];
$phone=$_POST['phone'];
$fax=$_POST['fax'];
$where=$_POST['where'];
$interest=$_POST['interest
$message=$_POST['message']
//
$tema=$_POST['tema'];
$paginaOK=$_POST['pagina_o
$paginaERROR=$_POST['pagin
//////////////////////////
// FECHA ...
$fecha=date("m-d-Y");
// EMAIL REMITENTE / DESTINATARIO ...
$from = $re_email;
$to="info@xxxxx.com";
// ASUNTO...
$subject = $tema;
//
//
//////////////////////////
//
// HTML - BODY ...
//
$salto = "\n";
//
$body="-------------------
//
$body.="Date: ".$fecha.$salto;
$body.="Category: ".$category.$salto;
$body.="Name: ".$name.$salto;
$body.="E-mail: ".$re_email.$salto;
$body.="Company: ".$company.$salto;
$body.="Street: ".$street.$salto;
$body.="City: ".$city.$salto;
$body.="State: ".$state.$salto;
$body.="Zip: ".$zip.$salto;
$body.="Phone: ".$phone.$salto;
$body.="Fax: ".$fax.$salto;
$body.="Where: ".$where.$salto;
$body.="Interest: ".$interest.$salto;
$body.="Message: ".$message.$salto;
//
$body.="------------------
//
// ENCABEZADO / CONTENT ...
//
//
$headers = "From: $from\r\n";
$headers .= "MIME-Version: 1.0\r\n";
//$headers .= "Content-Type: text/html; charset=iso-8859-1;";
//
//$content="<html><head></
$content.= $body;
//$content.="</body></html
//
//////////////////////////
//
// ENVヘA EL EMAIL...
//
$checkEmail=mail($to, $subject, $content, $headers);
//$to="info@xxxxx.com";
//$checkEmail2=mail($to, $subject, $content, $headers);
//
// VERIFICA EL ENVヘO...
//
//if ($checkEmail && $checkEmail2) {
if ($checkEmail) {
header("Location: $paginaOK");
} else {
header("Location: $paginaERROR");
}
//
// FIN //
//
}
?>
**************************
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER