Reputation: 55
I have the following form on each of my website pages:
<section class="footer-one">
<form action="sendmail.php" method="post" onsubmit="return validateForm()">
<div>
<div class="row half">
<div class="6u">
<input type="text" class="text" name="name" id="contact_phone" placeholder="מספר טלפון" onfocus="if (this.value == ' טלפון נייד') this.value = '';" onchange=" telephoneCheck1()"/>
</div>
<div class="6u">
<input type="text" class="text" name="name" id="contact_name" onfocus="if (this.value == ' שם מלא') this.value = '';" onchange="nameCheck1" name="contact_name" placeholder="שם מלא" />
</div>
</div>
<div class="row half">
<div class="12u">
<textarea name="message" id="comments" placeholder=" תוכן ההודעה"></textarea>
</div>
</div>
<div class="row">
<div class="12u">
<ul class="actions">
<li><input type="submit" class="button button-style1" value="שלח" /></li>
<li><input type="reset" class="button button-style2" value="אפס" /></li>
</ul>
</div>
</div>
</div>
</form>
</section>
it is connected to the following php:
<?php
header ('Location: http://www.intrahouse.co.il ');
if(isset($_POST['email'])) {
$email_to = "[email protected]";
$email_subject = "פנייה מהאתר";
$first_name = $_POST['contact_name'];
$telephone = $_POST['contact_phone'];
$comments = $_POST['comments'];
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message = "Form details below.\n\n";
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
}
?>
there is also a jquery for spam checking:
var name_success = false;
var phone_success = false;
function validateForm()
{
if (name_success == true && phone_success == true)
{
alert("הפנייה נשלח בהצלח");
return true;
}
if (name_success == false)
{
alert("שגיאה, ציין שם ושם משפחה תקין");
return false;
}
if (phone_success == false)
{
alert("שגיאה, מספר הפלאפון שציינת אינו תקין");
return false;
}
}
function nameCheck1(){
var reg=/\w{3,50}/;
var fname = document.getElementById("first_name").value;
if(reg.test(fname)){
name_success = true;
}
else{
alert("שגיאה, ציין שם ושם משפחה תקין");
name_success = false;
}
}
function telephoneCheck1(){
var telephone = document.getElementById("telephone").value;
var phone = telephone.replace(/\s|-/g,'');
var reg=/^\d+$/;
if(reg.test(phone)){
phone_success = true;
}
else{
alert("שגיאה, מספר הפלאפון שציינת אינו תקין");
phone_success = false;
}
}
I'm missing something since it won't send me any emails... the form doesn't work :\ thanks
Upvotes: 0
Views: 68
Reputation: 93
Also your script is redirecting you to index page and try also the suggestion of niet th dark apostol suggested. Remove first line of script.php header or put it to some place taht makes sense.
Upvotes: 0
Reputation: 986
Your problem is here:
<input type="text"
class="text"
name="name"
id="contact_phone"
placeholder=" מספר
טלפון ". onfocus="if (this.value == ' טלפון נייד ') this.value = '';" onchange=" telephoneCheck1()"/> this.value = '';" onchange="nameCheck1" name="contact_name" placeholder=" שם מלא " />
Change it to:
<input type="text" class="text". name="contact_phone"
id="contact_phone"
placeholder=" מספר
טלפון " onfocus="if (this.value == ' טלפון נייד ') this.value = '';" onchange=" telephoneCheck1()"/>
Upvotes: 0
Reputation: 324620
You have no element with name="email"
. As such, isset($_POST['email'])
simply cannot be true, hence no email is sent.
Either add the name
you are looking for, or look for a name
that does exist.
Additionally, you have two name="name"
elements (although the second one has a second name
attribute... consider revising!)
Upvotes: 1