Been looking at this for Days

So ive tried and tested server fine so it cant be server issues, but when i use this i just dont receive the email at all
ive obviously misse out the to and from secs here

<?php 
if(isset($_POST['submit'])){
    $to = "test@.com"; // this is your Email address
    $from = $_POST['test@.com']; // this is the sender's Email address
    $Name = Trim(stripcslashes( $_POST['Name']));
    $Email = Trim(stripcslashes( $_POST['Email']));
    $Phone = Trim(stripcslashes( $_POST['Phone']));
    $Message = Trim(stripcslashes(  $_POST['message']));
    $How_can_we_help = $_POST['How_can_we_help'];
	
    $subject2 = "Copy of your form submission";
    $message = $Name . " " . $How_can_we_help . " wrote the following:" . "\n\n" . $_POST['message'];
    $message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];

    $headers = "From:" . $from;
    $headers2 = "From:" . $to;
    @mail($to,$subject,$message,$headers);
    @mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
    echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
    // You can also use header('Location: thank_you.php'); to redirect to another page.
    }
?>

and the html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Hanwell Fields Community Centre</title>
    <META NAME="Description" CONTENT="">
    <meta name="Keywords" content=", , " /
    <!-- Bootstrap and css-->
    <link href="bootstrap.min.css" rel="stylesheet">
    <link href="bootstrap.min.js" rel="stylesheet">
    <link href="style.css" rel="stylesheet">
    
    
  
   </head>
  
  
  
  
  <body>
		  
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href="index.html">Hanwells Community Centre
              </a>
    </div>
     <ul class="nav navbar-nav navbar-right">
        <li><a href="about.html">About Us</a></li>
        <li><a href="time.html">Time Table</a></li>	
        <li><a href="book.html">Bookings</a></li>	
        <li><a href="events.html">Community Events</a></li>	
  </div>
</nav>

 	
<!--  COntent  -->
<div class="head-img">
			 <div class="container text-center">
		<img class="img-responsive" src="booking.jpg" style= "width: 1000px; height 200px;"
			</div>
		</div>	




		<div class="book container text-center">
		  <div class="row">
			<div class="col-md-3">
			    <h1>contact our office </h1>
			    <p><Hanwell Fields Community Centre<br>
			        Rotary Way<br>
			        Banbury, OX16 1ER.<br>
			        E-mail: admin@hanwell-fields.co.uk<br>
			        Telephone: 01295 258431
			        </p>
			
			   </div>
			   
			   
			   
			   <div class="social col-md-3">
			    <h1>contact Us on social media </h1>
			   <ul class="decoration-type-none">
			   
			   <li> <button class="btn btn-muted btn-lg">Facebook</button></li><br>
			   <li> <button class="btn btn-muted btn-lg">Twitter</button></li><br>
		<!--	   <li> <button class="btn btn-muted btn-lg">default</button></li>
			-->   
			   
			   </ul>
			
			   </div>
			   
			   
			   
			   
			   
			   
			  
			         <div class="col-md-3">
  <div class="contactus">
						  
							  
	<form role="form" required="true" method="post" action="email.php" onsubmit="if(document.getElementById('agree').checked) { return true; } else { alert('Please indicate that you have read and agree to the Hire Terms agreement'); return false; }">
								
	   <div class="form-group">
		   <label>Name </label>
		   <input type="text" class="form-control" placeholder="Your Name"> 
	   </div>
							   
							   
	   <div class="form-group">
     	   <label>Email </label>
		   <input type="email" class="form-control" placeholder="Your Email"> 
	   </div>
							   
	      <div class="form-group">
     	   <label>Phone </label>
		   <input type="text" class="form-control" placeholder="Your Telephone Number"> 
	   </div>
	   
	   					   
	   <div class="form-group">
		   <label>Message </label>
		   <textarea class="form-control" placeholder="Your Message"></textarea>
	   </div>
	
	
	    <div class="form-group ">
           <label>How can we help </label>
           <select class="form-control">
           <option value="Hire Venue">Hire Venue</option>
           <option value="Information">Information</option>
           <option value="other">Other</option>
           </select>
           </div>
	
	     

       <input type="checkbox" name="checkbox" value="check" id="agree" /> I have read and agree to the <a target="_blank" href="javascript:void window.open('http://http://hanwellfields.com/terms.html','','scrollbars=yes,menubar=yes,resizable=yes,left=30,top=30,height=500,width=650')"> Hire Terms</a>

	 <hr>
	<button type="submit" class="btn btn-default">Send</button>
	
	
							   
  </div>
						  	
			
</div>

		</div>




    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="bootstrap.min.js"></script>
  </body>
</html>

Take out the @ before the mail so it doesn’t suppress any errors.
@mail

Then perhaps an if() statement to see how far it gets?

if(mail(......)) {
    echo 'Sent';
} else {
    echo 'Fail';
}

Just as a very basic check.

hey dood so whilst waiting for a reply i have already took @ off and still no joy thank you for your reply am i adding the echo to the end of the code then?

Yes so your mail line becomes:

if(mail($to,$subject,$message,$headers)) {
    echo 'Sent';
} else {
    echo 'Fail';
}

However looking at the code it appears that you are not actually sending $_POST[‘submit’] from the form!
Your button is:

	<button type="submit" class="btn btn-default">Send</button>

change to

	<button type="submit" name="submit" class="btn btn-default">Send</button>
1 Like

well that one worked cheers buddy but still now i can receive the email but there is nothing in it and the email address i am sending from isnt working…

Basically i want it so people can enquire with a short email in order to be contacted in return…

You are almost there.

Go through your form and make sure that all the form inputs have a NAME attribute.
Otherwise they wont be referenced when you POST the form.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.