表单的解析错误

时间:2013-07-02 02:36:42

标签: php

我在Parse error: syntax error, unexpected T_IF获得if (mail($to, $subject, $body, $header))我已关闭semi-colons。我找不到为什么它会出现If语句

的问题
 <?php
    include('dbconnect.php');

    if (isset($_POST['submit']))
    {

        ...

        $to = 'sent@sent.com';
        $subject = $_POST['Subject'];
        $header = 'From:' .$_POST['Email'];
        $message = 
        'New fedback sent by  
        First Name: '.$_POST['FirstName'].' 
        Last Name: '.$_POST['LastName'].'
        about '.$_POST['Subject'].' 
        Message: '.$_POST['msg'].' 
        '

        if (mail($to, $subject, $body, $header))
        {

    }   
?>

2 个答案:

答案 0 :(得分:2)

您需要关闭$message作业,例如;

 $message = 
    'New fedback sent by  
    First Name: '.$_POST['FirstName'].' 
    Last Name: '.$_POST['LastName'].'
    about '.$_POST['Subject'].' 
    Message: '.$_POST['msg'].' 
    ';

答案 1 :(得分:1)

此:

    $message = 
    'New fedback sent by  
    First Name: '.$_POST['FirstName'].' 
    Last Name: '.$_POST['LastName'].'
    about '.$_POST['Subject'].' 
    Message: '.$_POST['msg'].' 
    '

缺少结束分号;。你需要关闭它:

    $message = 
    'New fedback sent by  
    First Name: '.$_POST['FirstName'].' 
    Last Name: '.$_POST['LastName'].'
    about '.$_POST['Subject'].' 
    Message: '.$_POST['msg'];