Jump to content

crispybean

Recommended Posts

Hi there,

After battling this problem for hours I have bitten the bullet and am asking for HELP! sad.gif

My contact form is not working, it was working, then wasn't...then was and now its definately not! The thankyou page is appearing when I have filled in the details and click SUBMIT- I am just not receiving the email.

Here is my form HTML coding (I have highlighted the code that I think is making the form work and not work- as explained below! (file name contactus.html)

 

 

 

 

 

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>Contact Us</title>

 

<link href="layout.css" rel="stylesheet" type="text/css">

<link href="slider.css" rel="stylesheet" type="text/css">

<link href="fonts.css" rel="stylesheet" type="text/css">

<link href="fonts/sourcecode/stylesheet.css" rel="stylesheet" type="text/css">

<link href="fonts/umbrage/stylesheet.css" rel="stylesheet" type="text/css">

<link href="fonts/maidenorange/stylesheet.css" rel="stylesheet" type="text/css">

<link href="fonts/helvetica/stylesheet.css" rel="stylesheet" type="text/css">

 

<!--Internet Explorer Script start-->

<script>

function check(input) {

if (input.value != document.getElementById('email_addr').value) {

input.setCustomValidity('The two email addresses must match.');

} else {

// input is valid -- reset the error message

input.setCustomValidity('');

}

}

</script>

 

<script>

document.createElement("article");

document.createElement("footer");

document.createElement("header");

document.createElement("section");

document.createElement("nav");

</script>

<!--Internet Explorer Script end-->

 

<script type="text/javascript" src="js/jquery-1.3.1.min.js"></script>

<script type="text/javascript" src="js/jquery.scrollTo.js"></script>

 

<script>

 

$(document).ready(function() {

 

$('a.panel').click(function () {

 

$('a.panel').removeClass('selected');

$(this).addClass('selected');

 

current = $(this);

 

$('#wrapper').scrollTo($(this).attr('href'), 800);

 

return false;

});

 

$(window).resize(function () {

resizePanel();

});

 

});

 

function resizePanel() {

 

width = $(window).width();

height = $(window).height();

 

mask_width = width * $('.item').length;

 

$('#debug').html(width + ' ' + height + ' ' + mask_width);

 

$('#wrapper, .item').css({width: width, height: height});

$('#mask').css({width: mask_width, height: height});

$('#wrapper').scrollTo($('a.selected').attr('href'), 0);

 

}

 

</script>

<style type="text/css">

body section {

color: #000;

}

body section p {

color: #000;

text-align: center;

}

#outersection article form table {

font-size: 18px;

}

</style>

</head>

 

<body>

<!--start navigation-->

<nav>

<ul>

<li><a href="index.html">home</a>

</li>

<li><a href="aboutus.html">about us</a></li>

<li><a href="products.html">products</a>

</li>

<li><a href="demos.html">demos</a></li>

<li><a href="contactus.html">contact us</a>

</ul>

</nav>

<!--end navigation-->

 

 

<!--start header-->

<section>

<header> <h1>Order online here</h1> </header>

</section>

 

<section id ="outersection">

<article>

 

<form name="html_form_send" method="post" action="thankyou.html">

<table width="450px">

</tr>

<tr>

<td valign="top">

<label for="first_name">First Name *</label>

</td>

<td valign="top">

<input type="text" name="first_name" maxlength="50" size="30">

</td>

</tr>

 

<tr>

<td valign="top">

<label for="last_name">Last Name *</label>

</td>

<td valign="top">

<input type="text" name="last_name" maxlength="50" size="30">

</td>

</tr>

<tr>

<td valign="top">

<label for="email">Email Address *</label>

</td>

<td valign="top">

<input type="text" name="email" maxlength="80" size="30">

</td>

 

</tr>

<tr>

<td valign="top">

<label for="telephone">Telephone Number</label>

</td>

<td valign="top">

<input type="text" name="telephone" maxlength="30" size="30">

</td>

</tr>

<tr>

<td valign="top">

<label for="comments">Products Requested*</label>

</td>

<td valign="top">

<textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea>

</td>

 

</tr>

<tr>

<td colspan="2" style="text-align:center">

 

<input type="submit" value="Submit"></td>

</tr>

</table>

</form>

 

 

</article>

 

</section>

 

<section>

<p>Have any further queries or questions we can assist you with?

Email us <a href="mailto:sales@xxxxxxx">HERE</a></p>

</section>

 

 

 

 

<!-- start small section-->

 

<article id= "information">

<h1> Thankyou for visiting us at Autolecs.com.au</h1>

</article>

<!--end small section-->

 

 

<!-- start footer-->

<footer>

<p></p>

</footer>

<!--end footer-->

 

</body>

</html>

 

 

 

 

 

AND my php coding; (file name send_form_email.php)

 

 

 

 

 

 

 

<?php

if(isset($_POST['email'])) {

// EDIT THE 2 LINES BELOW AS REQUIRED

$email_to = "sales@xxxxxxxxxx";

$email_subject = "Order Received";

function died($error) {

// your error code can go here

echo "We are very sorry, but there were error(s) found with the form you submitted. ";

echo "These errors appear below.<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'])) {

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);

 

?>

 

<!-- include your own success html here -->

<title>contactform</title>

 

 

 

 

<h1>Thank you for your order - one of our friendly sales team will confirm your order soon</h1>

 

Plus I have a confirmation page (file named thankyou.html)

 

 

 

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>THANKYOU!</title>

 

<link href="layout.css" rel="stylesheet" type="text/css">

<link href="fonts.css" rel="stylesheet" type="text/css">

<link href="fonts/sourcecode/stylesheet.css" rel="stylesheet" type="text/css">

<link href="fonts/umbrage/stylesheet.css" rel="stylesheet" type="text/css">

<link href="fonts/maidenorange/stylesheet.css" rel="stylesheet" type="text/css">

 

 

 

<!--Internet Explorer Script start-->

 

<script>

document.createElement("article");

document.createElement("footer");

document.createElement("header");

document.createElement("section");

document.createElement("nav");

</script>

 

<!--Internet Explorer Script end-->

 

 

<style type="text/css">

#outersection #information h1 {

color: #FF0;

}

</style>

</head>

 

<body>

<!--start navigation-->

 

<nav>

<ul>

<li><a href="index.html">home</a>

</li>

<li><a href="aboutus.html">about us</a></li>

<li><a href="products.html">products</a>

</li>

<li><a href="demos.html">demos</a></li>

<li><a href="contactus.html">contact us</a>

</li></ul>

</nav>

<!--end navigation-->

 

 

<!--start header-->

 

<!--end header-->

 

 

<!--start main section-->

 

 

 

<!--end main section-->

 

 

<!-- start small section-->

<section id ="outersection">

<article id= "information">

<h1> </h1>

<h1> </h1>

<h1> </h1>

<h1> </h1>

<h1> </h1>

<h1>Thankyou - your order has been received and</h1>

<h1>you will be contacted shortly by one of our </h1>

<h1>friendly sales team!</h1>

</article>

</section>

<!--end small section-->

 

 

<!-- start footer-->

<footer>

<p></p>

</footer>

<!--end footer-->

 

</body>

</html>

 

 

Now, the problem (I think) lies in the highlighted row of HTML code. When I changed it to this the EMAIL worked, but the thankyou page did not appear- just basic text on a blank screen that when clicked 'back' from you are sent back to the form or if closed, closed the whole browser. plain.gif When changed back to the orginal the thankyou page appeared but no email...

Is there a simple answer to get BOTH actions working?! I would be forever thankful for anyone's assistance, this is my first live site and my client has been very patient so far...but time is ticking!

Thanking anyone for any assistance!

PS- I am a beginner, this is my first live site- go easy on me!

Link to comment
Share on other sites

Well the first thing I noticed if that the action of your form is a HTML page.. I don't know how your php is supposed to run?

 

And also I can't see where you've highlighted the line of HTML that you think is the problem. What you should do is make "send_form_email.php" the action of the form, then at the end of the script, use header('Location thankyou.html'); to forward the user on to the thankyou page.

 

Hope that makes sense.

Denno

Link to comment
Share on other sites

Thanks for the quick response Denno- just to clarify do I place the header in the PHP file? As below;

 

 

<?php

if(isset($_POST['email'])) {

 

// EDIT THE 2 LINES BELOW AS REQUIRED

$email_to = "sales@xxxxxx.com.au";

$email_subject = "Order Received";

 

 

function died($error) {

// your error code can go here

echo "We are very sorry, but there were error(s) found with the form you submitted. ";

echo "These errors appear below.<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'])) {

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);

 

header ('Location thankyou.html');

 

?>

 

<!-- include your own success html here -->

<title>contactform</title>

 

 

 

 

 

 

<h1>Thank you for your order - one of our friendly sales team will confirm your order soon</h1>

Link to comment
Share on other sites

Yep, right at the end of the php file. It will redirect the users browser. Also add an exit(); right after the header. Just to make sure the php script isn't processed any further.

I know there isn't any more code after it, but I tend to put them together anyways.

 

Denno

Link to comment
Share on other sites

Still no love! I now have this error appearing when I click submit. Parse error: syntax error unexpected $end in /home/dxxxxxxx/public_html/xxxxxxx.com.au/send_form_email.php on line 84

 

Here is the code as entered in DW, looks all kosher apart from a red highlighted line that has appeared on the line as mentioned above! There is no code on this line?

 

 

<?php

if(isset($_POST['email'])) {

 

// EDIT THE 2 LINES BELOW AS REQUIRED

$email_to = "sales@xxxxxxxxx";

$email_subject = "Order Received";

 

 

function died($error) {

// your error code can go here

echo "We are very sorry, but there were error(s) found with the form you submitted. ";

echo "These errors appear below.<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'])) {

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);

 

header('Location thankyou.html');

exit()

 

?>

 

<!-- include your own success html here -->

 

 

What have I done now?! :confused: :'(

<title>contactform</title>

 

 

 

 

<h1>Thank you for your order - one of our friendly sales team will confirm your order soon</h1>

Edited by crispybean
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.