I try to send an email using php and a simple form. The code is uploaded:
http://webofdreams.ro/tests/basic%20template.html
The send email form is under sent to a friend. The problem is that the email is not sent and the submit button disappears after it was clicked. If there is another button (let's say cancel) after pressing cancel the code is run, but not email is sent.
The code running on the server is as simple as it gets:
<?php
$mailTo = $_POST['emailTo'];
$mailFrom = $_POST['emailFrom'];
$name = $_POST['name'];
$message = 'Your friend ' . $name . 'recommends this Web site: ';
$subject = $name . 'recommends Fine Maid';
mail($mailTo, $subject, $message);
echo "Mail Sent.";
?>
Edit:
html:
<html>
<ul>
<li><a href="#" title="">Call us</a>
<div class="navLinks"> </div>
</li>
<li><a href="#">Visit our website</a>
<div class="navLinks"> Content Here </div>
</li>
<li><a href="#">Email us</a>
<div class="navLinks"> Content Here </div>
</li>
<li><a href="#">Send to a friend</a>
<div class="navLinks">
<form name="send-to-friend" id="form2" method="post" action="sendemail.php">
<label for="name" class="blockItem">Your Name</label>
<input type="text" class="blockItem" id="name" name="name" maxlength="60" size="30"/>
<label for="emailFrom" class="blockItem">Your Email</label>
<input type="text" class="blockItem" id="emailFrom" name="emailFrom" maxlength="60" size="30" />
<label for="emailTo" class="blockItem">Your friend's email</label>
<input type="text" class="blockItem" id="emailTo" name="emailTo" maxlength="60" size="30" value="" />
<input class="button" id="submit" type="submit" value="Send Message"/>
<!--<input class="button" type="submit" value="Cancel" />-->
</form>
</div>
</li>
</ul>
</html>
CSS:
.nav ul {
list-style-type:none;}
.nav {
float: right;
line-height: 3.3em;
}
.nav li {
margin: 0 .5em;
display: inline-block;
}
.nav li a {
color: #000;
font-size: 1.1em;
}
.navLinks {
position: absolute;
top: 3em;
background: #2C75D8;
padding: 0 5px;
border: 2px solid #94afd3;
-moz-box-shadow: 0 0 4px #fff;
-webkit-box-shadow: 0 0 4px #fff;
box-shadow: 0 0 4px #bbb;
-webkit-border-radius: 7px;
-moz-border-radius: 7px;
border-radius: 7px;
z-index: 1000;
}
form {
font-family: Tahoma, Geneva, sans-serif;
font-size: 14px;
line-height: 1.5em;
color: #ddd;
text-decoration: none;
padding: 1em;
margin-bottom: 1em;
}
label {
margin: 10px 0 0 0;
}
.blockItem {
display: block;
}
.error {
display: block;
color: #FF8080;
}
.button {
display: inline;
margin-top: 10px;
}
span {
color: #F00;
}
jquery:
$(document).ready(function() {
$('.commentContainer:odd').addClass('darker');
$('#hideButton').click(function() {
$(this).hide();
});
$('.navLinks').hide();
$(".nav a").on("click", function(e) {
$(".navLinks").hide();
$(this).siblings(".navLinks").show();
e.preventDefault();
});
});