Jump to content

PHP form troubles


SwiftEagle92

Recommended Posts

Hello, I am currently designing a few websites that all need contact forms to send the information collected by the form to a certain email address. I have done the HTML and even attempted to code the PHP. But for some reason, the form gets submitted but no email comes through, I have checked all possible folders on the email so I have come to the conclusion that my form PHP is not working at all. If you guys could help me out or show me what to do I would really appreciate it. 

 

 

My HTML code:

<form id="contact" action="formsub.php" enctype="multipart/form-data" method="post">
    <h2>Our Contact Form</h2>
		<p> Fill out all the fields provided below, then press the submit form button at the bottom and a member of our team will get in touch between 24 / 48 hours.</p>
    <h4>Square Well Cover</h4>
		<input name="Tightest Internal Square" placeholder="Tightest Internal Square Height" type="text" >
		<label> X </label>
		<input name="Tightest Internal Square" placeholder="Tightest Internal Square Width" type="text" >
		<h4> Circle Well Covers</h4>
		<input name="tightestinternaldiameterheight" placeholder="Tightest Internal Diameter" type="text" >
    <h4> Steel Frame Glass Required? </h4>
  <input type='checkbox' class='fs1' name="steelframeyes" value="Yes" checked="checked"> <h3> Yes</h3><br>
    <input type='checkbox' class='fs1' name="steelframeno" value="No" > <h3> No</h3><br>
    <h4> Width of Top Course Blocks</h4>
    <input name="widthoftopcornerofblocks" placeholder="Width Of Top Corner Blocks" type="text">
		
		<h4>Upload Drawings</h4>
		<label for="file-upload" class="custom-file-upload">
    Image Upload
</label>
    <button name="submit" type="submit" id="contact-submit" data-submit="...Sending">Submit Form</button>
		<div class="g-recaptcha" data-sitekey="6Lc5rSkUAAAAAN6yv2OJ_jm1LoPUFe3dWShby7ye"></div>
    </form>

PHP (Form Sub)

<?
$button = $_POST ['submit'];
$name = $_POST ['fullname'];
$rawemail = $_POST ['email'];
$contact = $_POST ['contactnumber'];
$question = $_POST ['message'];
$name = $_Post ['tightestinternaldiameterheight'];
$name = $_Post ['tightestinternaldiameterwidth'];
$name = $_Post ['tightestdiametercircle'];
$name = $_Post ['steelframeyes'];
$name = $_Post ['steelframeno'];
$name = $_Post ['steelframemaybe'];
$name = $_Post ['widthoftopcornerofblocks'];
$name = $_Post ['ventilationyes'];
$name = $_Post ['ventilationno'];
$name = $_Post ['paintedborderyes'];
$name = $_Post ['paintedborderno'];
$name = $_Post ['ritecyes'];
$name = $_Post ['ritecno'];
$name = $_Post ['message'];
$name = $_Post ['installationyes'];
$name = $_Post ['installationno'];



$ouremail = 'pixarman@hotmail.co.uk';

     $subject = "walk on glass enquiry form completed by $fullname";
    $message = "Name of new client:  $name" . "\n Contact Number: $contact" . " \n Website URL: $website" . " \n Message: " . "$question";

     $headers = "From: $rawemail" . "\r\n" .
    "Reply-To: $rawemail" . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
         mail($ouremail,$subject,$message,$headers);


include('thankyou.html');
?>

HTML_Form_Send PHP

<?php
if(isset($_POST['email'])) {

	// CHANGE THE TWO LINES BELOW
	$email_to = "pixarman@hotmail.co.uk";

	$email_subject = "website html form submissions";


	function died($error) {
		// your error code can go here
		echo "We're sorry, but there's errors found with the form you submitted.<br /><br />";
		echo $error."<br /><br />";
		echo "Please go back and fix these errors.<br /><br />";
		die();
	}

	// validation expected data exists
	if(!isset($_POST['first_name']) ||
		!isset($_POST['last_name']) ||
		!isset($_POST['email']) ||
		!isset($_POST['telephone']) ||
		!isset($_POST['comments'])) ||
    !isset($_Post)['contactnumber'])) ||
		!isset($_Post)['message'])) ||
		!isset($_Post)['tightestinternaldiameterheight'] ))||
		!isset($_Post)['tightestinternaldiameterwidth'] ))||
		!isset($_Post)['tightestdiametercircle'] )) ||
		!isset($_Post) ['steelframeyes'] )) ||
		!isset($_Post) ['steelframeno'] )) ||
		!isset($_Post) ['steelframemaybe'] )) ||
		!isset($_Post) ['widthoftopcornerofblocks'] )) ||
		!isset($_Post)['ventilationyes'] )) ||
		!isset($_Post)['ventilationno'] )) ||
		!isset($_Post)['paintedborderyes'] )) ||
		!isset($_Post) ['paintedborderno'] )) ||
		!isset($_Post) ['ritecyes'] )) ||
		!isset($_Post)['ritecno'])) ||
		!isset($_Post)['installationyes'])) ||
		!isset($_Post)['installationno'])) ||


			)
		{
		died('We are sorry, but there appears to be a problem with the form you submitted.');
	}

	$first_name = $_POST['first_name']; // required
	$last_name = $_POST['last_name']; // required
	$email_from = $_POST['email']; // required
	$telephone = $_POST['telephone']; // not required
	$comments = $_POST['comments']; // required

	$error_message = "";
	$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email_from)) {
  	$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
	$string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$first_name)) {
  	$error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }
  if(!preg_match($string_exp,$last_name)) {
  	$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
  	$error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
  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 .= "first name: ".clean_string($first_name)."\n";
	$email_message .= "last name: ".clean_string($last_name)."\n";
	$email_message .= "email: ".clean_string($email_from)."\n";
	$email_message .= "telephone: ".clean_string($telephone)."\n";
	$email_message .= "comments: ".clean_string($comments)."\n";


// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>

<!-- place your own success html below -->

include('thankyou.html');

<?php
}
die();
?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.