Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    67
    Thanks
    20
    Thanked 1 Time in 1 Post

    PHP Error in mail()

    I have this to enable somone to send a message to someone.
    PHP Code:
    <?php    


    $from
    =$_POST['email_from'];
    $to=$_POST['email_to'];
    $subject=$_POST['subject'];
    $message=$_POST['message'];

    mail($to,$subject,$message,$from); 
    ?>
    The error message my site is giving me is
    Parse error: syntax error, unexpected T_STRING, expecting ']' in /home/a5461089/public_html/action.php on line 6

    any help
    Last edited by UltimateCoder; 02-01-2012 at 04:02 PM.

  • #2
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,234
    Thanks
    51
    Thanked 100 Times in 99 Posts
    You forgot a single quote.

    PHP Code:
    $to=$_POST[email_to]; 
    Change to this

    PHP Code:
    $to=$_POST['email_to']; 
    Been a sign maker for 7 years. My business:
    American Made Signs

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    You'd have found it yourself if you had used the [PHP][/PHP] tags to wrap your code, like
    PHP Code:
    <?php    


    $from
    =$_POST['email_from'];
    $to=$_POST['email_to];
    $subject=$_POST['
    subject'];
    $message=$_POST['
    message];

    mail($to,$subject,$message,$from); 
    ?>
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    tangoforce (01-31-2012)

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,091
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Quote Originally Posted by abduraooft View Post
    You'd have found it yourself if you had used the [PHP][/PHP] tags to wrap your code, like
    PHP Code:
    <?php    


    $from
    =$_POST['email_from'];
    $to=$_POST['email_to];
    $subject=$_POST['
    subject'];
    $message=$_POST['
    message];

    mail($to,$subject,$message,$from); 
    ?>
    Well said. How ironic is it that 'UltimateCoder' can't see these things?

    @'UltimateCoder': You should also be using mail() inside an if() conditional to test that it is accepted by sendmail.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!


  •  

    Posting Permissions

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