Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Help with contact form

  • 18-09-2009 7:01am
    #1
    Closed Accounts Posts: 1,493 ✭✭✭


    Ok this is my first time trying to set up a contact form, however I keep getting this...
    Parse error: parse error in D:\hshome\#######\########.com\contactformprocess.php on line 30
    ..error message when I hit send.

    [PHP]<?php

    /* Subject and email variables */

    $emailSubject = 'PHP Scripting ';
    $webMaster = '######@#####.ie';

    /* Gathering data variables*/

    $nameField = $_POST;
    $emailField = $_POST;
    $phoneField = $_POST;
    $queriesField = $_POST;

    $body = <<<EOD
    <br><hr><br>
    Name: $name <br>
    Email: $email <br>
    Phone: $phone <br>
    Queries: $queries <br>
    EOD;

    $headers = "From: $email\r\n";
    $headers .= "Content-type: text/html\r\n";

    $success = mail($webMaster, $emailSubject, $body, $headers)

    /* Results rendered as HTML */

    $theResults = <<<EOD
    <html>
    <head>
    <title>Untitled Document</title>
    </head>

    <body>
    sent successfully
    </body>
    </html>EOD;

    echo "$theResults";

    ?>[/PHP]
    Line 30 is
    $theResults = <<<EOD

    I've copied this pretty much word for word from a youtube tutorial & I can't see any difference. Can anybody help? It's surely something simple.


Comments

  • Registered Users, Registered Users 2 Posts: 912 ✭✭✭chakotha


    I've never heard of <<<EOD in PHP.

    try
    $body = "<br><hr><br>
    Name: $name <br>
    Email: $email <br>
    Phone: $phone <br>
    Queries: $queries <br>";

    You are missing a semi-colon from the end of the mail function call.

    And I'd wrap the $theResults HTML block in quotes too and do away with the EOD.


  • Closed Accounts Posts: 1,493 ✭✭✭eddiehead


    chakotha wrote: »
    I've never heard of <<<EOD in PHP.

    try

    You are missing a semi-colon from the end of the mail function call.

    And I'd wrap the $theResults HTML block in quotes too and do away with the EOD.

    Tbh I have absolutely zero knowledge of PHP, so I can't even explain why >>>EOD is in there, like I said I just followed the instructions on the tutorial. I'll try that when I get home for lunch, thanks.


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    The "<<<" (heredoc syntax) is designed to allow you to set a variable until the pattern (in this case "EOD") is encountered; it lets you avoid all of the issues related to escaping quotes.

    A rough tutorial is available here : http://www.phpf1.com/tutorial/php-heredoc-syntax.html

    The issue in this case, however, is the lack of a semi-colon on the PRECEDING line :
    $success = mail($webMaster, $emailSubject, $body, $headers)[b];[/b]
    


  • Registered Users, Registered Users 2 Posts: 6,571 ✭✭✭daymobrew


    I sometimes use an online PHP Syntax checker when I get compile time errors. (I'm too lazy to open my command line and use php.exe syntax checker).


  • Closed Accounts Posts: 1,493 ✭✭✭eddiehead


    Liam Byrne wrote: »
    The issue in this case, however, is the lack of a semi-colon on the PRECEDING line :
    $success = mail($webMaster, $emailSubject, $body, $headers)[b];[/b]
    

    Are you saying the <<<EOD thing is fine then and I just need to add a semi-colon to the line you quoted?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 6,571 ✭✭✭daymobrew


    eddiehead wrote: »
    Are you saying the <<<EOD thing is fine then and I just need to add a semi-colon to the line you quoted?
    In the online syntax checker I had to add the semicolon and move the "EOD;" text onto a new line.
    [PHP]$success = mail($webMaster, $emailSubject, $body, $headers);[/PHP]
    [PHP]</html>
    EOD;[/PHP]


  • Closed Accounts Posts: 1,493 ✭✭✭eddiehead


    Thanks for the help lads.

    It's all good now as far as the PHP is concerned, its processing the form and getting to the "sent" screen. However, the form is not making it to my inbox. What do I need to do to make the form go to my email address? Is this something I need to arrange on the server side?


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    Assuming that the $webMaster variable is set to the correct address, try adding or removing either the \r or the \n within the headers; I've found this (occasionally) to be a platform-specific issue (depending on whether you're hosted on Windows or Unix, or the version of PHP).


Advertisement