SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 33
  1. #1
    SitePoint Addict
    Join Date
    Nov 2012
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

    Code:
    <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...lidation.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 Code:
    <?php 
    $errors 
    '';
    $myemail 'antonylambert@c5d.co.uk';//<-----Put Your email address here.
    if(empty($_POST['name']) || 
    empty(
    $_POST['email']) || 
    empty(
    $_POST['message']))
    {
    $errors .= "\n 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 .= "\n 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:\n Name: $name \n Email: $email_address \n Message \n $message"

    $headers "From: $myemail\n"
    $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
    Last edited by ralph.m; Feb 10, 2013 at 07:14. Reason: added code tags

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    PHP Code:
    //redirect to the 'thank you' page
    header('http://www.c5d.co.uk/changeofaddress.php'); 
    change that to:
    PHP Code:
    //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.

  3. #3
    SitePoint Addict
    Join Date
    Nov 2012
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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
    Code HTML4Strict:
    <!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 .= "\n 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 .= "\n 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:\n Name: $name \n Email: $email_address \n Message \n $message"; 
     
    $headers = "From: $myemail\n"; 
    $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>
    Last edited by Dark Tranquility; Feb 10, 2013 at 05:23. Reason: Code highlight

  4. #4
    SitePoint Mentor bronze trophy
    ronpat's Avatar
    Join Date
    Jun 2012
    Location
    NJ, USA
    Posts
    2,620
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)
    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 [code] tags typed as follows:

    [code]
    paste your code here
    [/code]

    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 [code] 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 [code] 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 [code] tags for you.
    The php symbol at the very right end inserts [php] tags.

    In all cases, the generic [code] tags are far more helpful than none at all.

    Thanks

  5. #5
    SitePoint Mentor bronze trophy
    ronpat's Avatar
    Join Date
    Jun 2012
    Location
    NJ, USA
    Posts
    2,620
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)
    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

  6. #6
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,331
    Mentioned
    463 Post(s)
    Tagged
    8 Thread(s)
    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.

  7. #7
    SitePoint Addict
    Join Date
    Nov 2012
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  8. #8
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,331
    Mentioned
    463 Post(s)
    Tagged
    8 Thread(s)
    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 Code:
    <?php 
    $errors 
    '';
     
    $myemail 'antonylambert@c5d.co.uk';//<-----Put Your email address here.
     
    if(empty($_POST['name']) || 
    empty(
    $_POST['email']) || 
    empty(
    $_POST['message']))
     {
     
    $errors .= "\n 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 .= "\n 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:\n Name: $name \n Email: $email_address \n Message \n $message"
     
    $headers "From: $myemail\n"
    $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.

  9. #9
    SitePoint Mentor bronze trophy
    ronpat's Avatar
    Join Date
    Jun 2012
    Location
    NJ, USA
    Posts
    2,620
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)
    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.


  10. #10
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,331
    Mentioned
    463 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by ronpat View Post
    What do ya'll think?

    I could easily be misinterpreting things, so please correct any of my misconceptions .
    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).

  11. #11
    SitePoint Mentor bronze trophy
    ronpat's Avatar
    Join Date
    Jun 2012
    Location
    NJ, USA
    Posts
    2,620
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)
    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

  12. #12
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,331
    Mentioned
    463 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by ronpat View Post
    an on-page JavaScript data validation method which would have eliminated the php calls to the server. Maybe it would be worth reconsidering.
    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.

  13. #13
    SitePoint Mentor bronze trophy
    ronpat's Avatar
    Join Date
    Jun 2012
    Location
    NJ, USA
    Posts
    2,620
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)
    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.

  14. #14
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,331
    Mentioned
    463 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by ronpat View Post
    I think I need to back off and "read the mail" on this issue for a bit.
    Not at all. These are good questions. Remember also that I know little about this subject, but I do find it fascinating. 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.

  15. #15
    SitePoint Addict
    Join Date
    Nov 2012
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  16. #16
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,331
    Mentioned
    463 Post(s)
    Tagged
    8 Thread(s)
    Sorry for the error. I should have added a } at the very end of that code. Add that in and see what happens.

    Quote Originally Posted by certificates View Post
    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.
    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.

  17. #17
    SitePoint Addict
    Join Date
    Nov 2012
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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 Code:
    <?php 
    $errors 
    '';
     
    $myemail 'antonylambert@c5d.co.uk';//<-----Put Your email address here.
     
    if(empty($_POST['name']) || 
    empty(
    $_POST['email']) || 
    empty(
    $_POST['message']))
     {
     
    $errors .= "\n 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 .= "\n 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:\n Name: $name \n Email: $email_address \n Message \n $message"
     
    $headers "From: $myemail\n"
    $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>'
    ;}

  18. #18
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,331
    Mentioned
    463 Post(s)
    Tagged
    8 Thread(s)
    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:

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

    with the original code you had:

    Code:
    echo nl2br($errors);
    Unless someone who knows PHP steps in, we'll just have to stumble along like this.

    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 Code:
    <?php 

    $errors
    =array();
     
    $myemail 'antonylambert@c5d.co.uk';//<-----Put Your email address here.
     
    if(empty($_POST['name']) || 
    empty(
    $_POST['email']) || 
    empty(
    $_POST['message']))
     {
     
    $errors[] = "\n 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[] = "\n 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:\n Name: $name \n Email: $email_address \n Message \n $message"
     
    $headers "From: $myemail\n"
    $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>'
    ;}

  19. #19
    SitePoint Addict
    Join Date
    Nov 2012
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  20. #20
    SitePoint Addict
    Join Date
    Nov 2012
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Apache Error in PHP Form Help: This must e simple for a PHP man, but not for me

    I am very new to PHP and have a problem with a conatct form.

    I have drawn up my form and it sends the details through, but instead of going to the successful page called ackofdetails.php, I get this message

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



    My contact form seems OK

    This is it. Underneath is the page which contains the necessary coding to send the info



    Code HTML4Strict:
    <!DOCTYPE html> 
    <html lang="en"><head> <meta charset="utf-8">
        <title> Change of Address| Welcome To The Ashton Under Lyne Golf Club Website</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">
     
     
    <ul class="opendays">
     <li>
     <p><strong>Change of Peronal Details</strong></p>
     </li>
     </ul>
     
     
     
     
    <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 [url]http://www.javascript-coder.com/html...lidation.phtml[/url]
    // 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>
                </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/teetimetwo.php"><img src="http://www.c5d.co.uk/tee-time.png" alt="book a tee"/></a>
                                <a href="http://www.c5d.co.uk/hurstweathertwo.php"><img class="ad125" src="http://www.c5d.co.uk/hurstweather.jpg" alt="Weather Widget" /></a>
                               <a href="http://www.c5d.co.uk/teetimetwo.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/notwittertwo.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/notwittertwo.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>


    This is the change of adress page where I guess the mechanics are done


    Code PHP:
    <?php 
    $errors = '';
     $myemail = 'antonylambert@c5d.co.uk';//<-----Put Your email address here.
     if(empty($_POST['name']) || 
    empty($_POST['email']) || 
    empty($_POST['message']))
     {
     $errors .= "\n 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 .= "\n 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:\n Name: $name \n Email: $email_address \n Message \n $message"; 
     
    $headers = "From: $myemail\n"; 
    $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;">';
     
    echo nl2br($errors);
    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>';}

    What am I doing wrong


    Antony
    Last edited by guido2004; Feb 11, 2013 at 01:00. Reason: added code tags

  21. #21
    SitePoint Addict
    Join Date
    Nov 2012
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If anyone is trying to help by sending the contact from test@test.com it's coming through but twice

  22. #22
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,331
    Mentioned
    463 Post(s)
    Tagged
    8 Thread(s)
    Yeah, I was testing the form. OK, it's interesting that it arrives, yet you still get the server error. Most discussions about this online tell you either to—

    a) contact your host or
    b) check your server's error log to see what the error was

  23. #23
    SitePoint Mentor bronze trophy
    ronpat's Avatar
    Join Date
    Jun 2012
    Location
    NJ, USA
    Posts
    2,620
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)
    Antony, please give this page a run and tell us how it fails. Thanks.

    You will probably have to correct some file names.

    Code:
    <!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>
    <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 -->
            <div class="span-24">
                <div id="pagemenucontainer">
                    <ul id="pagemenu" class="menu">
                        <li><a href="http://www.c5d.co.uk/addresschange.php">Change of Address</a></li>
                        <li><a href="http://www.c5d.co.uk/contactagc.php">Contact Us</a></li>
                        <li><a href="http://www.c5d.co.uk/directionstoclub.php">Directions</a></li>
                    </ul>
                </div>
            </div>
            <div id="header" class="span-24">
                <div class="span-12">
                    <img class="clubphoto" src="http://www.c5d.co.uk/clubhouse.jpg" alt="clubhouse" height="210" width="950">
                </div>
            </div>
            <div class="span-24">
                <div id="navcontainer">
                    <ul id="nav" class="menu">
                        <li><a href="/index.php"><img src="http://www.c5d.co.uk/home.gif" alt="home"></a></li>
                        <li><a href="index.php">Visitors' Info</a>
                            <ul class="sub-menu">
                                <li><a href="http://www.c5d.co.uk/coursehistory.php">Club History</a></li>
                                <li><a href="http://www.c5d.co.uk/clubhousefacilities.php">Clubhouse Facilities</a></li>
                                <li><a href="http://www.c5d.co.uk/society-menu.php">Society Menu</a></li>
                                <li><a href="http://www.c5d.co.uk/dresscode.php">Dress Code</a></li>
                                <li><a href="http://www.c5d.co.uk/greenfees.php">Green Fees</a></li>
                                <li><a href="http://www.c5d.co.uk/teetime.php">Book A Tee Time</a></li>
                            </ul>
                        </li>
                        <li><a href="http://www.c5d.co.uk/course.php">Course</a>
                            <ul class="sub-menu">
                                <li><a href="http://www.c5d.co.uk/course.php">Course Photos</a></li>
                                <li><a href="http://www.c5d.co.uk/clubcard.php">Card</a></li>
                                <li><a href="http://www.c5d.co.uk/clubrecord.php">Course Record</a></li>
                            </ul>
                        </li>
                        <li><a href="http://www.c5d.co.uk/clubcompetitions.php">Club Comps</a>
                            <ul class="sub-menu">
                                <li><a href="http://www.c5d.co.uk/winners2012.php">Major Trophy Winners 2012</a></li>
                                <li><a href="http://www.c5d.co.uk/nov2012.php">Competition Results November 2012</a></li>
                                <li><a href="http://www.c5d.co.uk/dec2012.php">Competition Results December 2012</a></li>
                                <li><a href="http://www.c5d.co.uk/jan2013.php">Competition Results January 2013</a></li>
                                <li><a href="http://www.c5d.co.uk/feb2013.php">Competition Results February 2013</a></li>
                            </ul>
                        </li>
                        <li><a href="http://www.c5d.co.uk/clubteams.php">Club Teams</a>
                            <ul class="sub-menu">
                                <li><a href="http://www.c5d.co.uk/teammatches2013.php">A &amp; B Team Matches 2013</a></li>
                                <li><a href="http://www.c5d.co.uk/seniorteam.php">Senior Fixtures 2013</a></li>
                                <li><a href="http://www.c5d.co.uk/dunham.php">Dunham Forest Trophy 2013</a></li>
                                <li><a href="http://www.c5d.co.uk/mos.php">Mail on Sunday Knock Out 2013</a></li>
                                <li><a href="http://www.c5d.co.uk/dmf.php">Daily Mail Foursome Knock Out 2013</a></li>
                                <li><a href="http://www.c5d.co.uk/cityglass.php">City Glass Foursomes 2013</a></li>
                                <li><a href="http://www.c5d.co.uk/archie.php">Archie Preston Trophy 2013</a></li>
                                <li><a href="http://www.c5d.co.uk/bmw.php">Williams BMW Junior Challenge 2013</a></li>
                                <li><a href="http://www.c5d.co.uk/teammatches2012.php">A &amp; B Team Results 2012</a></li>
                                <li><a href="http://www.c5d.co.uk/ladiesteam.php">Ladies Team 2012</a></li>
                                <li><a href="http://www.c5d.co.uk/juniorteam.php">Junior Team 2012</a></li>
                            </ul>
                        </li>
                        <li><a href="http://www.c5d.co.uk/opens.php">Opens 2013</a>
                            <ul class="sub-menu">
                                <li><a href="http://www.c5d.co.uk/gentsopens.php">Gentlemen's Open Competitions 2013</a></li>
                                <li><a href="http://www.c5d.co.uk/ladiesopens.php">Ladies' Open Competitions 2013</a></li>
                                <li><a href="http://www.c5d.co.uk/mixedopens.php">Mixed Open Competitions 2013</a></li>
                                <li><a href="http://www.c5d.co.uk/seniorsopens.php">Senior Open Competitions 2013</a></li>
                                <li><a href="http://www.c5d.co.uk/junioropen.php">Junior Open Competition 2013</a></li>
                            </ul>
                        </li>
                        <li><a href="http://www.c5d.co.uk/events.php">Club Diary</a>
                            <ul class="sub-menu">
                                <li><a href="http://www.c5d.co.uk/calendar.php">Gentlemen's Events</a></li>
                                <li><a href="http://www.c5d.co.uk/ladiescalendar.php">Laides' Events</a></li>
                                <li><a href="http://www.c5d.co.uk/seniorcalendar.php">Seniors' Events</a></li>
                                <li><a href="http://www.c5d.co.uk/juniorcalendar.php">Juniors' Events</a></li>
                                <li><a href="http://www.c5d.co.uk/social.php">Social Events</a></li>
                            </ul>
                        </li>
                        <li><a href="http://www.c5d.co.uk/news.php">News</a>
                            <ul class="sub-menu">
                                <li><a href="http://www.c5d.co.uk/news1112.php">November 2012</a></li>
                                <li><a href="http://www.c5d.co.uk/news1212.php">December 2012</a></li>
                                <li><a href="http://www.c5d.co.uk/news0113.php">January 2013</a></li>
                                <li><a href="http://www.c5d.co.uk/news0213.php">February 2013</a></li>
                            </ul>
                        </li>
                        <li><a href="http://www.c5d.co.uk/sections.php">Club Sections</a>
                            <ul class="sub-menu">
                                <li><a href="http://www.c5d.co.uk/greens.php">Greens Team</a></li>
                                <li><a href="http://www.c5d.co.uk/handicaps.php">Handicap Secretary</a></li>
                                <li><a href="http://www.c5d.co.uk/comps.php">Competitions Team</a></li>
                                <li><a href="http://www.c5d.co.uk/bar.php">Bar &amp; House Secretaries</a></li>
                                <li><a href="http://www.c5d.co.uk/juniors.php">Juniors</a></li>
                                <li><a href="http://www.c5d.co.uk/golfclublinks.php">Related Links</a></li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
    <!-- END menu.php INCLUDE -->
            <div class="span-24" id="contentwrap" style="background:#E0E0E0;">
                <div class="span-13">
                    <div id="content">
                        <div class="entry">
                            <div id="ai1ec-container" class="ai1ec-container thenly">
                                <h2>Sorry, there was an error!</h2>
    <?php
    $errors = '';
    $myemail = 'antonylambert@c5d.co.uk';//<-----Put Your email address here.
    if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['message'])) {
        $errors .= "\n 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 .= "\n 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:\n Name: $name \n Email: $email_address \n Message \n $message";
    $headers = "From: $myemail\n";
    $headers .= "Reply-To: $email_address";
    mail($to,$email_subject,$email_body,$headers);
    //redirect to the 'thank you' page
    header('Location: thankyou.php');
    exit();
    }
    echo nl2br($errors); ?>
                            </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>
    </body>
    </html>

  24. #24
    SitePoint Addict
    Join Date
    Nov 2012
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think we might have done it.

    The messages took a long time to come through but eventually they did.

    Thanks for all the help.

    If you'd like to give it a go as some one from off my site to my e mail address that would be great.

    Just type any old rubbish in.


    The final bit of this puzzle is just to amend the boxes to get the info I want.

    Should be a doddle (;-))) Fingers crossed

    Antony

  25. #25
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,331
    Mentioned
    463 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by certificates View Post
    The final bit of this puzzle is just to amend the boxes to get the info I want.
    Which boxes do you mean?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •