Hi and thanks in advance if you are able to help me.
I am new to php and using a tempate with the following code which sends me the email OK but the sent email does not show the name and I can't work put why..!
HTML FORM
<div class="contact-form">
<form class="contact-form" method="post" action="/">
<p class="contact-form-name">
<label for="name">Name <span class="required">*</span></label>
<input type="text" aria-required="true" size="30" value="" name="name" id="name" class="form-control" placeholder="Your Name">
</p>
<p class="contact-form-email">
<label for="email">Email <span class="required">*</span></label>
<input type="email" aria-required="true" size="30" value="" name="email" id="email" class="form-control" placeholder="Your email">
</p>
<p class="contact-form-subject">
<label for="subject">Subject</label>
<input type="text" size="30" value="" name="subject" id="subject" class="form-control" placeholder="Your Subject">
</p>
<p class="contact-form-message">
<label for="message">Comment</label>
<textarea aria-required="true" rows="8" cols="45" name="message" id="message" class="form-control" placeholder=""></textarea>
</p>
<p class="contact-form-submit">
<input type="submit" value="Send Your Message" id="contact_form_submit" name="contact_submit" class="theme_btn">
</p>
</form>
</div>
contact-form.php
<?php
//Specify default values
//Your E-mail
$your_email = '
[email protected]';
//Default Subject if 'subject' field not specified
$default_subject = 'From My Contact Form';
//Message if 'name' field not specified
$name_not_specified = 'Please type a valid name';
//Message if 'message' field not specified
$message_not_specified = 'Please type a vaild message';
//Message if e-mail sent successfully
$email_was_sent = 'Thanks, your message successfully sent';
//Message if e-mail not sent (server not configured)
$server_not_configured = 'Sorry, mail server not configured';
//Contact Form Processing
$errors = array();
if(isset($_POST['message']) and isset($_POST['name'])) {
if(!empty($_POST['name']))
$sender_name = stripslashes(strip_tags(trim($_POST['name'])));
if(!empty($_POST['message']))
$message = stripslashes(strip_tags(trim($_POST['message'])));
if(!empty($_POST['email']))
$sender_email = stripslashes(strip_tags(trim($_POST['email'])));
if(!empty($_POST['subject']))
$subject = stripslashes(strip_tags(trim($_POST['subject'])));
//Message if no sender name was specified
if(empty($sender_name)) {
$errors[] = $name_not_specified;
}
//Message if no message was specified
if(empty($message)) {
$errors[] = $message_not_specified;
}
$from = (!empty($sender_email)) ? 'From: '.$sender_email : '';
$subject = (!empty($subject)) ? $subject : $default_subject;
$message = (!empty($message)) ? wordwrap($message, 70) : '';
//sending message if no errors
if(empty($errors)) {
if (mail($your_email, $subject, $message, $from)) {
echo $email_was_sent;
} else {
$errors[] = $server_not_configured;
echo implode('<br>', $errors );
}
} else {
echo implode('<br>', $errors );
}
}
?>