Hello…
My problem is that I have created the form and formtoemail.php and everything works fine and now I created a list to choose the product…
Here is the list:
[php]
And the current FormToEmail.php code
[php]
<?php if(isset($_POST['email'])) {// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "info@clm-pro-tk";
$email_subject = "Your email subject line";
function died($error) {
// your error code can go here
echo "Ispričavano se, prilikom po?iljanja va?eg upita smo prona?li pogre?ku/e. ";
echo "Pogre?ka/e će biti prikazane ispod.<br /><br />";
echo $error."<br /><br />";
echo "Vrni se i popravi.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['ime']) ||
!isset($_POST['email']) ||
!isset($_POST['naslov']) ||
!isset($_POST['poruka'])) {
died('Ispričavamo se, prona?li smo npogre?ku prilikom slanja va?eg upita.');
}
$ime = $_POST['ime']; // required
$email = $_POST['email']; // required
$naslov = $_POST['naslov']; // required
$poruka = $_POST['poruka']; // required
$trup = $_POST[‘select’] ; // not required
$newsletter = $_POST[‘newsletter’]; // not required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email)) {
$error_message .= ‘E-mail ne valja.
’;
}
$string_exp = “/^[A-Za-z .’-]+$/”;
if(!preg_match($string_exp,$ime)) {
$error_message .= ‘Ime ne valja.
’;
}
if(strlen($naslov) < 2) {
$error_message .= ‘Naslov ne valja.
’;
}
if(strlen($poruka) < 2) {
$error_message .= ‘Poruka ne valja.
’;
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = “Form details below.\n\n”;
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Ime: ".clean_string($ime)."\n";
$email_message .= "Email: ".clean_string($email)."\n";
$email_message .= "Naslov: ".clean_string($naslov)."\n";
$email_message .= "Poruka: ".clean_string($poruka)."\n";
// create email headers
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email . “\r\n” .
‘X-Mailer: PHP/’ . phpversion();
@ mail(“[email protected]”, $naslov,
$poruka, “From:” . $email . “\r\n” . $newsletter . “\r\n” . $trup . “\r\n” . $ime);
//AUTO RESPONCE MESSAGE
//Create main headers
$pporuka = “”;
$pporuka .= "Po?tovani ";
$pporuka .= $ime;
$pporuka .= ", hvala na vasem upitu u vezi proizvoda: ";
$pporuka .= $trup;
$pporuka .= ", javit cemo vas se u ?to kracem roku. ";
$pporuka .= "
Upitali ste nas slijedece: ";
$pporuka .= $poruka;
//E-mails subject
//Send the email
mail($email, $naslov, $pporuka, “From:” . “[email protected]”);
?>
Thank you for contacting us. We will be in touch with you very soon.
<?php } ?>[/php]The error messages are on Croatian but you don’t have to bother with that…
The problem is that the default selected item is Please choose(translated to english) and I need in the formtoemail to say if the select(that list) is “Molim odaberite” --> please choose then send an error message like for other parameters… and if it is Trup #100 - Trup #114 then do nothing and submit form
I think there is a simple msolution but I can’t remember any -.-
Thank you in advance!