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 05:02 PM.

  • #2
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,559
    Thanks
    76
    Thanked 105 Times in 104 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,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    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,474
    Thanks
    63
    Thanked 537 Times in 524 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.
    I can't really think of anything to write here now...


  •  

    Posting Permissions

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