My form nearly works but not quite. The success page is missing

I can’t say I haven’t tried to do this myself but have just failed. Having searched contact form after contact form, I have almost achieved the most simple one of all.

It e mails the details, but the one problem is have clicked submit you get a blank page. You end up on www.c5d.co.uk/send_contact.php

This is the change of address page: www.c5d.co.uk/addresschange.php and this is what I have put in there. I don’t know if the javascript is necessary but it was on the free form.

<form method="POST" name="contactform" action="changeofaddress.php"> 
<p>
<label for='name'>Your Name:</label> <br>
<input type="text" name="name">
</p>
<p>
<label for='email'>Email Address:</label> <br>
<input type="text" name="email"> <br>
</p>
<p>
<label for='message'>Message:</label> <br>
<textarea name="message"></textarea>
</p>
<input type="submit" value="Submit"><br>
</form>

<script language="JavaScript">
// Code for validating the form
// Visit http://www.javascript-coder.com/html-form/javascript-form-validation.phtml
// for details
var frmvalidator = new Validator("contactform");
frmvalidator.addValidation("name","req","Please provide your name"); 
frmvalidator.addValidation("email","req","Please provide your email"); 
frmvalidator.addValidation("email","email","Please enter a valid email address"); 
</script>

As instructed, I then created a page call www.c5d.co.uk/changeofaddress.php with this code.


<?php 
$errors = '';
$myemail = 'antonylambert@c5d.co.uk';//<-----Put Your email address here.
if(empty($_POST['name']) || 
empty($_POST['email']) || 
empty($_POST['message']))
{
$errors .= "\
 Error: all fields are required";
}

$name = $_POST['name']; 
$email_address = $_POST['email']; 
$message = $_POST['message']; 

if (!preg_match(
"/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$/i", 
$email_address))
{
$errors .= "\
 Error: Invalid email address";
}

if( empty($errors))
{
$to = $myemail; 
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new message. ".
" Here are the details:\
 Name: $name \
 Email: $email_address \
 Message \
 $message"; 

$headers = "From: $myemail\
"; 
$headers .= "Reply-To: $email_address";

mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('http://www.c5d.co.uk/changeofaddress.php');
} 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
<title>Change of Address</title>
</head>

<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
?>
</body>
</html>

The message comes through OK, but the success page has the following across the middle

Warning: Cannot modify header information - headers already sent by (output started at /websites/123reg/LinuxPackage21/c5/d_/co/c5d.co.uk/public_html/changeofaddress.php:8) in /websites/123reg/LinuxPackage21/c5/d_/co/c5d.co.uk/public_html/changeofaddress.php on line 72

What I want it to say is " Thanks for submitting your information"

It e mails the details, but the one problem is have clicked submit you get a blank page. You end up on www.c5d.co.uk/send_contact.php

This is the change of address page: www.c5d.co.uk/addresschange.php and this is what I have put in there. I don’t know if the javascript is necessary but it was on the free form.

Where am I going wrong?

Antony


//redirect to the 'thank you' page
header('http://www.c5d.co.uk/changeofaddress.php');

change that to:


//redirect to the 'thank you' page
header('thankyou.php');
exit();

and create a page called thankyou.php with the message in it.

If that does not cure that error – which is caused because your page is outputting something onto the page prior to calling header(); then you should comment out blocks of code until you find out what it is.

Are you certain that’s all I need to change because it doesn’t seem to make any difference.

The form comes through but I still get the same blurb across the success page

Here is the full code of the page


<!DOCTYPE html> 
<html lang="en"><head> <meta charset="utf-8">
    <title>Welcome To The Ashton Under Lyne Golf Club Website: Change of Address</title>
   
    <link rel="stylesheet" href="http://www.c5d.co.uk/clubstyle.css" type="text/css" media="screen">
    <link rel="stylesheet" href="http://www.c5d.co.uk/MenuMatic.css" type="text/css" media="screen">
   
    <script src="http://www.c5d.co.uk/mootools-1.2.5-core-yc.js" type="text/javascript"></script>
    <script src="http://www.c5d.co.uk/MenuMatic_0.68.3.js" type="text/javascript"></script>
</head><?php
$date = date(“format”, $timestamp);
?>
<body>

<script type="text/javascript">
    window.addEvent('domready', function() {
        var myMenu = new MenuMatic();
    });
</script>

<div id="wrapper">
    <div id="container" class="container">

<!-- BEGIN menu.php INCLUDE -->
<?php include $_SERVER["DOCUMENT_ROOT"] . "/includes/menu.php"; ?>
<!-- END menu.php INCLUDE -->
        <div>
            <div class="span-24" id="contentwrap" style="background:#E0E0E0;">
                <div class="span-13">
                    <div id="content">
                        <div style="position:relative;">
                            <div class="postwrap">
                                <div class="post" id="post-222" style="width:760px;">
                                    <div class="entry" style="position:relative;">
                                        <div id="ai1ec-container" class="ai1ec-container thenly">

<?php 
$errors = '';
 $myemail = 'antonylambert@c5d.co.uk';//<-----Put Your email address here.
 if(empty($_POST['name']) || 
empty($_POST['email']) || 
empty($_POST['message']))
 {
 $errors .= "\
 Error: all fields are required";
 }
 
$name = $_POST['name']; 
$email_address = $_POST['email']; 
$message = $_POST['message']; 

if (!preg_match(
 "/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$/i", 
$email_address))
 {
 $errors .= "\
 Error: Invalid email address";
 }
 
if( empty($errors))
 {
 $to = $myemail; 
$email_subject = "Contact form submission: $name";
 $email_body = "You have received a new message. ".
 " Here are the details:\
 Name: $name \
 Email: $email_address \
 Message \
 $message"; 

$headers = "From: $myemail\
"; 
$headers .= "Reply-To: $email_address";

 mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('thankyou.php');
exit(); 
 } 
?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
 <head>
 <title>Change of Address</title>
 </head>
 
<body>
 <!-- This page is displayed only if there is some error -->
 <?php
 echo nl2br($errors);
 ?>
 
</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="span-11 last">
                    <div class="span-7">
                        <div class="sidebar left-sidebar"></div>
                    </div>
                    <div class="span-4 last">
                       
                        <div class="sidebaradbox125">
                            <a href="http://www.brsgolf.com/ashtonunderlyne/visitor_availability_month.php"><img class="whatson" src="http://www.c5d.co.uk/whatson.png" alt="book a tee"/></a>
                            <a href="http://www.brsgolf.com/ashtonunderlyne/opens_home.php" target="_blank"><img class="ad125" src="http://www.c5d.co.uk/brsgolf.jpg" alt="Book An Open" /></a>
                            <a href="http://www.howdidido.co.uk" target="_blank"><img class="ad125" src="http://www.c5d.co.uk/howdidido.jpg" alt="How Did I Do" /></a>
                            <a href="http://www.c5d.co.uk/teetime.php"><img src="http://www.c5d.co.uk/tee-time.png" alt="book a tee"/></a>
                            <a href="http://www.c5d.co.uk/hurstweather.php"><img class="ad125" src="http://www.c5d.co.uk/hurstweather.jpg" alt="Weather Widget" /></a>
                           <a href="http://www.c5d.co.uk/teetime.php"></a>
                            </div>
                             <div class="sidebar right-sidebar"></div>
                        <div class="socialboxes">
                            <a href="http://www.facebook.com/home.php?sk=group_152294981498083&amp;ap=1" target="_blank"><img class="ad125" src="http://www.c5d.co.uk/facebook.png" alt="Facebook" height="25" width="130" />FACEBOOK</a>
                        </div>
                        <div class="socialboxes">
                            <a href="http://www.c5d.co.uk/notwitter.php"><img class="ad125" src="http://www.c5d.co.uk/twitter.png" alt="Follow Us" title="Follow Us" style="vertical-align:middle; margin-right:5px;" /></a>
                            <a href="http://www.c5d.co.uk/notwitter.php">Follow Us</a></div>
                    </div>
                </div>
            </div>
        
        <div class="span-24">
            <div id="footer" style="padding:6px; height:15px;">
                <span style="float:left;">Copyright © Antony Lambert</span><?php echo date('l j F Y - H:ia'); ?>
                    <span style="float:right;"><a href="http://www.c5d.co.uk/hurstpages.php" target="_blank">The Hurst Pages</a> by <a href="http://www.c5d.co.uk" target="_blank">Antony Lambert of C5D</a></span>
                </div>
            </div>
        </div>   
    </div>    
</div>    
</body>
</html>

[FONT=Verdana]Part 1

Antony,

At the end of a thread is a box titled “Quick Reply”. This is where messages are posted in the forum.

When you post code in a message, please surround that code with [color=blue][noparse]

[/noparse][/color] tags typed as follows:

[color=blue][noparse]

[/noparse][/color]
paste your code here
[color=blue][noparse]

[/noparse][/color]

As you know, posting code in a message does not preserve indents or formatting and some characters in proportionally spaced fonts are hard to spot.

Using [noparse]

[/noparse] tags makes code much easier for us to read and potentially saves vertical space in the message.

If it is not convenient to type the [noparse]

[/noparse] tags, then try this instead:

At the bottom right of the "Quick Reply" box is an orange button that says "Go Advanced".

Click that button.

The one row of command buttons in the "Quick Reply" box will be replaced with three rows of buttons.

The # symbol near the right end of the middle row inserts the [noparse]

[/noparse] tags for you.
The php symbol at the very right end inserts [noparse]

[/noparse] tags.

In all cases, the generic [noparse]

[/noparse] tags are far more helpful than none at all.

Thanks
[/FONT]

I started to post a Part 2, but my brain is tired. Will try again tomorrow afternoon.

Can someone tell me if it is possible for a user (like me) to read a php/html file without having the php calls interpreted? Not being able to see where calls are being made (and read the calling statements) is a bit of a problem. I’m pretty sure that it can’t be done, since that is a server side function, but I have to ask.

The code in the changeofaddress.php file appears to be seriously invalid.

Thanks

As ronpat notes, your page code is seriously messed up there. You can’t start your page with a doctype etc and then have another one further down—at least, not the way you’ve done it. So the thing to do here is first clarify what you are trying to do here, because it’s not clear to me. Firstly, what page does the form appear on? You would typically have an HTML page with a form on it. In the action=“” part of the form, you post the URL of the PHP page the contains the PHP code that will process the form. That PHP code will check the input data, and either end that data to you via email and divert the user to a thank you page, or divert the user to an Error page is there is a problem.

Alternatively, this can all be handled with fewer pages. for example, if the PHP script page finds an error, it can reload itself and inform the user of a problem, or, if all’s well, that page can reload itself and thank the user.

At the moment, your code does none of those things. So the first thing you need to clarify is what scenario you want to see.

What I am trying to do is to use this page http://www.c5d.co.uk/addresschange.php as a page for a change of address. I know that the current box needs amending, but that’s the second stage of my problem.

I then want visitors to be sent to a success page www.c5d.co.uk/changeofaddess.php I want the email message to go to my e mail address antonylambert@c5d.co.uk

Thanks for the help

Antony

What you really want your changeofaddress.php processing file to look like is something like this (i.e. with PHP starting at the top):

<?php 
$errors = '';
 $myemail = 'antonylambert@c5d.co.uk';//<-----Put Your email address here.
 if(empty($_POST['name']) || 
empty($_POST['email']) || 
empty($_POST['message']))
 {
 $errors .= "\
 Error: all fields are required";
 }
 
$name = $_POST['name']; 
$email_address = $_POST['email']; 
$message = $_POST['message']; 
 
if (!preg_match(
 "/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$/i", 
$email_address))
 {
 $errors .= "\
 Error: Invalid email address";
 }
 
if( empty($errors))
 {
 $to = $myemail; 
$email_subject = "Contact form submission: $name";
 $email_body = "You have received a new message. ".
 " Here are the details:\
 Name: $name \
 Email: $email_address \
 Message \
 $message"; 
 
$headers = "From: $myemail\
"; 
$headers .= "Reply-To: $email_address";
 
 mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('thankyou.php');
exit(); 
 } 
 
 
if ($errors) {
echo '<!DOCTYPE html> 
<html lang="en"><head> <meta charset="utf-8">
    <title>Oops! There was an error</title>
 
    <link rel="stylesheet" href="http://www.c5d.co.uk/clubstyle.css" type="text/css" media="screen">
    <link rel="stylesheet" href="http://www.c5d.co.uk/MenuMatic.css" type="text/css" media="screen">
 
    <script src="http://www.c5d.co.uk/mootools-1.2.5-core-yc.js" type="text/javascript"></script>
    <script src="http://www.c5d.co.uk/MenuMatic_0.68.3.js" type="text/javascript"></script>
</head>
<body>
 
<script type="text/javascript">
    window.addEvent("domready", function() {
        var myMenu = new MenuMatic();
    });
</script>
 
<div id="wrapper">
    <div id="container" class="container">
 
<!-- BEGIN menu.php INCLUDE -->
include $_SERVER["DOCUMENT_ROOT"] . "/includes/menu.php";
<!-- END menu.php INCLUDE -->
        <div>
            <div class="span-24" id="contentwrap" style="background:#E0E0E0;">
                <div class="span-13">
                    <div id="content">
                        <div style="position:relative;">
                            <div class="postwrap">
                                <div class="post" id="post-222" style="width:760px;">
                                    <div class="entry" style="position:relative;">
                                        <div id="ai1ec-container" class="ai1ec-container thenly">
                                         <h1>Sorry, there was an error!</h1>
                                          <p>Please note the errors below:</p>
                                          <ul style="color: red;">';

foreach ($errors as $err) {
echo '<li>'.$err.'</li>';
}
echo '</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="span-11 last">
                    <div class="span-7">
                        <div class="sidebar left-sidebar"></div>
                    </div>
                    <div class="span-4 last">
 
                        <div class="sidebaradbox125">
                            <a href="http://www.brsgolf.com/ashtonunderlyne/visitor_availability_month.php"><img class="whatson" src="http://www.c5d.co.uk/whatson.png" alt="book a tee"/></a>
                            <a href="http://www.brsgolf.com/ashtonunderlyne/opens_home.php" target="_blank"><img class="ad125" src="http://www.c5d.co.uk/brsgolf.jpg" alt="Book An Open" /></a>
                            <a href="http://www.howdidido.co.uk" target="_blank"><img class="ad125" src="http://www.c5d.co.uk/howdidido.jpg" alt="How Did I Do" /></a>
                            <a href="http://www.c5d.co.uk/teetime.php"><img src="http://www.c5d.co.uk/tee-time.png" alt="book a tee"/></a>
                            <a href="http://www.c5d.co.uk/hurstweather.php"><img class="ad125" src="http://www.c5d.co.uk/hurstweather.jpg" alt="Weather Widget" /></a>
                           <a href="http://www.c5d.co.uk/teetime.php"></a>
                            </div>
                             <div class="sidebar right-sidebar"></div>
                        <div class="socialboxes">
                            <a href="http://www.facebook.com/home.php?sk=group_152294981498083&amp;ap=1" target="_blank"><img class="ad125" src="http://www.c5d.co.uk/facebook.png" alt="Facebook" height="25" width="130" />FACEBOOK</a>
                        </div>
                        <div class="socialboxes">
                            <a href="http://www.c5d.co.uk/notwitter.php"><img class="ad125" src="http://www.c5d.co.uk/twitter.png" alt="Follow Us" title="Follow Us" style="vertical-align:middle; margin-right:5px;" /></a>
                            <a href="http://www.c5d.co.uk/notwitter.php">Follow Us</a></div>
                    </div>
                </div>
            </div>
 
        <div class="span-24">
            <div id="footer" style="padding:6px; height:15px;">
                <span style="float:left;">Copyright © Antony Lambert</span>'; echo date('l j F Y - H:ia'); echo '<span style="float:right;"><a href="http://www.c5d.co.uk/hurstpages.php" target="_blank">The Hurst Pages</a> by <a href="http://www.c5d.co.uk" target="_blank">Antony Lambert of C5D</a></span>
                </div>
            </div>
        </div>   
    </div>    
</div>    
</body>
</html>';

The above code still assumes that, upon success, the user will be landed on a separate thankyou.php page.

[FONT=Verdana]Ron’s rambling…

If I am reading the above correctly, it looks like the initial page is named:

http://www.c5d.co.uk/addresschange.php

<!DOCTYPE html>
<html lang=“en”><head> <meta charset=“utf-8”>
<title>Welcome To The Ashton Under Lyne Golf Club Website: Change of Address</title>

It looks like Antony tried to install a JavaScripted on-page data validation method, which would have been very efficent!, but couldn’t make it work, so along came Plan B.

Accordingly, the form transmits data to the changeofaddress.php file where the data is validated.

If it validates OK, then the e-mail with the new information should be sent to Antony and the user should be redirected to the “thank you” page.

If the data fails validation, then Ralph’s HTML below the validation php code will be opened in the user’s browser and the failure codes presented to the user. Noted: there is no “Try Again” button, the user is expected to use his browser’s “Back” button to return to the addresschange.php page.

For simplicity (separation of functions), I would like to propose a Plan C.

The changeofaddress.php would contain ONLY the php validation code and decision making/action code.

If the data validates correctly, then the e-mail is generated and the user is sent to the “thank you” page.

If the data fails validation, then the user is sent to an error page…

A new error page would be created which displays the error messages if data validation fails.

The difference between Plan B and Plan C is the addition of a redirect in the php file and the creation of the new error presentation page (the target of that new redirect), therefore no embedded HTML page would exist in the php file. (Both changes sound easy.) The “separation of functions” makes it more logical, therefore easier to manage.

What do ya’ll think?

I could easily be misinterpreting things, so please correct any of my misconceptions :).

PS: changeofaddress.php as it is currently designed is not really a “success” page, it is the “validate” page. I would think that the “success” page would be the “thank you” page. Terminology seems confusing to me.

[/FONT]

Makes sense, Ron, but there are other options, too. Having the error page as part of the PHP page has some advantages, such as being able to echo the whole form and include the user’s current answers (although that’s not set up here). Another option (the one I prefer) is to have everything on the one, original form page do everything. So the processing code is on the form page itself, and depending on the results, the user either gets a thanks message, or a list of errors, followed by the form with the original input data shown (preferably with the incorrect ones highlighted).

Thanks, Ralph. Yes, I agree with processing the data on the page with the form. It looks like Antony’s original intent was to use an on-page JavaScript data validation method which would have eliminated the php calls to the server. Maybe it would be worth reconsidering.

Cheers

JS can provide a nice validation enhancement, such that you get feedback on your input without having to refresh the page, but it’s only really useful as an enhancement. It’s still important to have the server-side version as a backup. People can have JS off, of course, and thus bypass JS validation. So the server-side code needs to be there to clean up anything that gets through the net.

If the entire form processing is left up to JS, you have an even bigger problem if JS is off, because the form won’t process at all.

Good point about JavaScript. Weirdly slipped my mind that JS can be disabled. I think I need to back off and “read the mail” on this issue for a bit. :slight_smile:

Not at all. These are good questions. Remember also that I know little about this subject, but I do find it fascinating. :smiley: I haven’t ventured far into the whole Ajax live validation stuff, but I’d love to master that. And I can just do the most basic bits of PHP. I can’t guarantee that what I posted above will work without soe modification.

Thanks for the replies.

I loaded the suggested script suggested by ralph.m and called it changeofaddress.php. I also changed this

//redirect to the ‘thank you’ page
header(‘thankyou.php’);

to

//redirect to the ‘changeofaddress’ page
header(‘changeofaddress.php’);

Which seemed logical to me. I cannot use the thankyou page because I akready have a thankyou.php in respect of orders.

When I try and use the form I get this error

Parse error: syntax error, unexpected $end in /websites/123reg/LinuxPackage21/c5/d_/co/c5d.co.uk/public_html/changeofaddress.php on line 122

LIne 122 is the last line. And nothing is sent

Kind regards

Antony

Sorry for the error. I should have added a } at the very end of that code. Add that in and see what happens.

You don’t want to return the user to this page itself, because it doesn’t contain any kind of thank you message. Just make some other thank you page, like thankyou.html, or success.php, and use that instead.

Well we are one step further on because the form now sends and sends the details, but I get a different error.

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

<<<<<Please contact the server administrator, www.123-support.co.uk and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache Server at www.c5d.co.uk Port 80>>>>>

Is it something I have done incorrectly, or does it mean that my host 123-won’t allow these forms ?

This is the new code with the } at the bottom. The redirect page being now ackofdetails.php

<?php 
$errors = '';
 $myemail = 'antonylambert@c5d.co.uk';//<-----Put Your email address here.
 if(empty($_POST['name']) || 
empty($_POST['email']) || 
empty($_POST['message']))
 {
 $errors .= "\
 Error: all fields are required";
 }
 
$name = $_POST['name']; 
$email_address = $_POST['email']; 
$message = $_POST['message']; 
 
if (!preg_match(
 "/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$/i", 
$email_address))
 {
 $errors .= "\
 Error: Invalid email address";
 }
 
if( empty($errors))
 {
 $to = $myemail; 
$email_subject = "Contact form submission: $name";
 $email_body = "You have received a new message. ".
 " Here are the details:\
 Name: $name \
 Email: $email_address \
 Message \
 $message"; 
 
$headers = "From: $myemail\
"; 
$headers .= "Reply-To: $email_address";
 
 mail($to,$email_subject,$email_body,$headers);
//redirect to the 'ackofdetails' page
header('ackofdetails.php');
exit(); 
 } 
 
 
if ($errors) {
echo '<!DOCTYPE html> 
<html lang="en"><head> <meta charset="utf-8">
    <title>Oops! There was an error</title>
 
    <link rel="stylesheet" href="http://www.c5d.co.uk/clubstyle.css" type="text/css" media="screen">
    <link rel="stylesheet" href="http://www.c5d.co.uk/MenuMatic.css" type="text/css" media="screen">
 
    <script src="http://www.c5d.co.uk/mootools-1.2.5-core-yc.js" type="text/javascript"></script>
    <script src="http://www.c5d.co.uk/MenuMatic_0.68.3.js" type="text/javascript"></script>
</head>
<body>
 
<script type="text/javascript">
    window.addEvent("domready", function() {
        var myMenu = new MenuMatic();
    });
</script>
 
<div id="wrapper">
    <div id="container" class="container">
 
<!-- BEGIN menu.php INCLUDE -->
include $_SERVER["DOCUMENT_ROOT"] . "/includes/menu.php";
<!-- END menu.php INCLUDE -->
        <div>
            <div class="span-24" id="contentwrap" style="background:#E0E0E0;">
                <div class="span-13">
                    <div id="content">
                        <div style="position:relative;">
                            <div class="postwrap">
                                <div class="post" id="post-222" style="width:760px;">
                                    <div class="entry" style="position:relative;">
                                        <div id="ai1ec-container" class="ai1ec-container thenly">
                                         <h1>Sorry, there was an error!</h1>
                                          <p>Please note the errors below:</p>
                                          <ul style="color: red;">';

foreach ($errors as $err) {
echo '<li>'.$err.'</li>';
}
echo '</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="span-11 last">
                    <div class="span-7">
                        <div class="sidebar left-sidebar"></div>
                    </div>
                    <div class="span-4 last">
 
                        <div class="sidebaradbox125">
                            <a href="http://www.brsgolf.com/ashtonunderlyne/visitor_availability_month.php"><img class="whatson" src="http://www.c5d.co.uk/whatson.png" alt="book a tee"/></a>
                            <a href="http://www.brsgolf.com/ashtonunderlyne/opens_home.php" target="_blank"><img class="ad125" src="http://www.c5d.co.uk/brsgolf.jpg" alt="Book An Open" /></a>
                            <a href="http://www.howdidido.co.uk" target="_blank"><img class="ad125" src="http://www.c5d.co.uk/howdidido.jpg" alt="How Did I Do" /></a>
                            <a href="http://www.c5d.co.uk/teetime.php"><img src="http://www.c5d.co.uk/tee-time.png" alt="book a tee"/></a>
                            <a href="http://www.c5d.co.uk/hurstweather.php"><img class="ad125" src="http://www.c5d.co.uk/hurstweather.jpg" alt="Weather Widget" /></a>
                           <a href="http://www.c5d.co.uk/teetime.php"></a>
                            </div>
                             <div class="sidebar right-sidebar"></div>
                        <div class="socialboxes">
                            <a href="http://www.facebook.com/home.php?sk=group_152294981498083&amp;ap=1" target="_blank"><img class="ad125" src="http://www.c5d.co.uk/facebook.png" alt="Facebook" height="25" width="130" />FACEBOOK</a>
                        </div>
                        <div class="socialboxes">
                            <a href="http://www.c5d.co.uk/notwitter.php"><img class="ad125" src="http://www.c5d.co.uk/twitter.png" alt="Follow Us" title="Follow Us" style="vertical-align:middle; margin-right:5px;" /></a>
                            <a href="http://www.c5d.co.uk/notwitter.php">Follow Us</a></div>
                    </div>
                </div>
            </div>
 
        <div class="span-24">
            <div id="footer" style="padding:6px; height:15px;">
                <span style="float:left;">Copyright © Antony Lambert</span>'; echo date('l j F Y - H:ia'); echo '<span style="float:right;"><a href="http://www.c5d.co.uk/hurstpages.php" target="_blank">The Hurst Pages</a> by <a href="http://www.c5d.co.uk" target="_blank">Antony Lambert of C5D</a></span>
                </div>
            </div>
        </div>   
    </div>    
</div>    
</body>
</html>';}

Hm, you are at least partly suffering from my inexperience with PHP, as I’ve made some kind of error around line 77. It seems $errors is not an array, though I thought it was. O well, you could try replacing this code:

foreach ($errors as $err) {
echo '<li>'.$err.'</li>';
}

with the original code you had:

echo nl2br($errors);

Unless someone who knows PHP steps in, we’ll just have to stumble along like this. :smiley:

Here is an alternate version of the page where I’ve attempted to turn $errors into a proper array, so feel free to try this out too. If it works, it will give a better resutl:

<?php 

$errors=array();
 $myemail = 'antonylambert@c5d.co.uk';//<-----Put Your email address here.
 if(empty($_POST['name']) || 
empty($_POST['email']) || 
empty($_POST['message']))
 {
 $errors[] = "\
 Error: all fields are required";
 }
 
$name = $_POST['name']; 
$email_address = $_POST['email']; 
$message = $_POST['message']; 
 
if (!preg_match(
 "/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$/i", 
$email_address))
 {
 $errors[] = "\
 Error: Invalid email address";
 }
 
if( empty($errors))
 {
 $to = $myemail; 
$email_subject = "Contact form submission: $name";
 $email_body = "You have received a new message. ".
 " Here are the details:\
 Name: $name \
 Email: $email_address \
 Message \
 $message"; 
 
$headers = "From: $myemail\
"; 
$headers .= "Reply-To: $email_address";
 
 mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('ackofdetails.php');
exit(); 
 } 
 
 
if ($errors) {
echo '<!DOCTYPE html> 
<html lang="en"><head> <meta charset="utf-8">
    <title>Oops! There was an error</title>
 
    <link rel="stylesheet" href="http://www.c5d.co.uk/clubstyle.css" type="text/css" media="screen">
    <link rel="stylesheet" href="http://www.c5d.co.uk/MenuMatic.css" type="text/css" media="screen">
 
    <script src="http://www.c5d.co.uk/mootools-1.2.5-core-yc.js" type="text/javascript"></script>
    <script src="http://www.c5d.co.uk/MenuMatic_0.68.3.js" type="text/javascript"></script>
</head>
<body>
 
<script type="text/javascript">
    window.addEvent("domready", function() {
        var myMenu = new MenuMatic();
    });
</script>
 
<div id="wrapper">
    <div id="container" class="container">
 
<!-- BEGIN menu.php INCLUDE -->
include $_SERVER["DOCUMENT_ROOT"] . "/includes/menu.php";
<!-- END menu.php INCLUDE -->
        <div>
            <div class="span-24" id="contentwrap" style="background:#E0E0E0;">
                <div class="span-13">
                    <div id="content">
                        <div style="position:relative;">
                            <div class="postwrap">
                                <div class="post" id="post-222" style="width:760px;">
                                    <div class="entry" style="position:relative;">
                                        <div id="ai1ec-container" class="ai1ec-container thenly">
                                         <h1>Sorry, there was an error!</h1>
                                          <p>Please note the errors below:</p>
                                          <ul style="color: red;">';

foreach ($errors as $err) {
echo '<li>'.$err.'</li>';
}
echo '</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="span-11 last">
                    <div class="span-7">
                        <div class="sidebar left-sidebar"></div>
                    </div>
                    <div class="span-4 last">
 
                        <div class="sidebaradbox125">
                            <a href="http://www.brsgolf.com/ashtonunderlyne/visitor_availability_month.php"><img class="whatson" src="http://www.c5d.co.uk/whatson.png" alt="book a tee"/></a>
                            <a href="http://www.brsgolf.com/ashtonunderlyne/opens_home.php" target="_blank"><img class="ad125" src="http://www.c5d.co.uk/brsgolf.jpg" alt="Book An Open" /></a>
                            <a href="http://www.howdidido.co.uk" target="_blank"><img class="ad125" src="http://www.c5d.co.uk/howdidido.jpg" alt="How Did I Do" /></a>
                            <a href="http://www.c5d.co.uk/teetime.php"><img src="http://www.c5d.co.uk/tee-time.png" alt="book a tee"/></a>
                            <a href="http://www.c5d.co.uk/hurstweather.php"><img class="ad125" src="http://www.c5d.co.uk/hurstweather.jpg" alt="Weather Widget" /></a>
                           <a href="http://www.c5d.co.uk/teetime.php"></a>
                            </div>
                             <div class="sidebar right-sidebar"></div>
                        <div class="socialboxes">
                            <a href="http://www.facebook.com/home.php?sk=group_152294981498083&amp;ap=1" target="_blank"><img class="ad125" src="http://www.c5d.co.uk/facebook.png" alt="Facebook" height="25" width="130" />FACEBOOK</a>
                        </div>
                        <div class="socialboxes">
                            <a href="http://www.c5d.co.uk/notwitter.php"><img class="ad125" src="http://www.c5d.co.uk/twitter.png" alt="Follow Us" title="Follow Us" style="vertical-align:middle; margin-right:5px;" /></a>
                            <a href="http://www.c5d.co.uk/notwitter.php">Follow Us</a></div>
                    </div>
                </div>
            </div>
 
        <div class="span-24">
            <div id="footer" style="padding:6px; height:15px;">
                <span style="float:left;">Copyright © Antony Lambert</span>'; echo date('l j F Y - H:ia'); echo '<span style="float:right;"><a href="http://www.c5d.co.uk/hurstpages.php" target="_blank">The Hurst Pages</a> by <a href="http://www.c5d.co.uk" target="_blank">Antony Lambert of C5D</a></span>
                </div>
            </div>
        </div>   
    </div>    
</div>    
</body>
</html>';}

It didn’t make any difference.

Same error but the form came through In an attempt to attract some one let me start a new thread called Apache Error

OK

Antony

If anyone is trying to help by sending the contact from test@test.com it’s coming through but twice