2011-06-22 29 views
1

はい私はこれをしていると信じていますが、パースエラー:パースエラー、予期しない$ endをC:\ wamp \ www \ contactform.phpの106行目に表示しています。私が考えることができると思うのは、else、elseif、間違っている場合、私はそれらが別のものになるかどうかを見るためにそれらを切り替えようとしています。しかし、これまでのところ何もありません。PHPで読み込み中にエラーが発生しました

</style> 
    </head> 
    <body> 
    <div id="container"> 
    <?php 
    if (isset($_POST['submit'])){ 
     if (trim($_POST['name'])==""){ 
      $strMessage="Please enter your name!"; 
      showForm($strMessage); 
     } elseif (isset($_POST['submit'])){ 
       if (trim($_POST['email'])==""){ 
        $strMessage="Please enter your email!"; 
        showForm($strMessage); 
       } 
       if(isset($_POST['submit'])){ 
        if (trim($_POST['username'])==""){ 
         $strMessage="Please enter your username!"; 
         showForm($strMessage); 
        } elseif ($_POST['pword1'] != $_POST['pword2']) { 
         $_POST['pword1'] = NULL; // Reset the values of pword1 so it is not in the form 
         $_POST['pword2'] = NULL; // Reset the values of pword2 so it is not in the form 
         $strMessage="Passwords do not match!"; 
         showForm($strMessage); 
        } elseif (strlen(trim($_POST['pword1']))<=3){ 
         $strMessage="Your password must be at least 4 characters long!"; 
         showForm($strMessage); 
        } else { 
         $strMessage="Thank you, your information has been submitted. Below is the  information you sent:"; 
         $strMessageBody.="Name: ".trim(stripslashes($_POST['name']))."<br />"; 
         $strMessageBody.="E-mail: ".trim(stripslashes($_POST['Email']))."<br />"; 
         $strMessageBody.="UserName: ".trim(stripslashes($_POST['username']))."<br />"; 
         $strMessageBody.="Password: ".trim(stripslashes($_POST['pword1']))."<br />"; 
         $strMessageBody.="Re-enter Password: ".trim(stripslashes($_POST['pword2']))."<br />"; 
         echo "<h1>".$strMessage."</h1>"; 
         echo $strMessageBody; 
        } 
       } else { 
        $strMessage= "Please fill out the form below to send your information:"; 
        showForm($strMessage); 
       } 
      } 
     ?> 
    </div> 
    </body> 
     </html> 
+3

あなたはよりよくインデントする方法を学ぶ必要があります。 (インデントには柔らかいタブを使います)コードを読むのは難しいです。いくつかの箇所でブレースが欠けているかもしれません。コードを正しくインデントします。それはチーム環境で他の開発者を助け、あなたが自分でも、それはあなたを助けるでしょう。 – FinalForm

+3

閉じる中括弧がありません。そして、ランダムに周りのものを切り替えることによってプログラミングは行われません。 – Jon

+3

87行目の 'else'の前の' .'は何ですか? – rid

答えて

3

私はこれがあなたの望むものだと信じています。あなたは "if(isset($ _ POST ['submit'])){"を2回繰り返しすぎています!

if (isset($_POST['submit'])){ 
    if (trim($_POST['name'])==""){ 
    $strMessage="Please enter your name!"; 
    showForm($strMessage); 
    } elseif (trim($_POST['email'])==""){ 
     $strMessage="Please enter your email!"; 
    showForm($strMessage); 
    } elseif (trim($_POST['username'])==""){ 
    $strMessage="Please enter your username!"; 
    showForm($strMessage); 
    } elseif ($_POST['pword1'] != $_POST['pword2']) { 
    $_POST['pword1'] = NULL; // Reset the values of pword1 so it is not in the form 
    $_POST['pword2'] = NULL; // Reset the values of pword2 so it is not in the form 
    $strMessage="Passwords do not match!"; 
    showForm($strMessage); 
    } elseif (strlen(trim($_POST['pword1']))<=3){ 
    $strMessage="Your password must be at least 4 characters long!"; 
    showForm($strMessage); 
    } else { 
    $strMessage="Thank you, your information has been submitted. Below is the  information you sent:"; 
    $strMessageBody.="Name: ".trim(stripslashes($_POST['name']))."<br />"; 
    $strMessageBody.="E-mail: ".trim(stripslashes($_POST['Email']))."<br />"; 
    $strMessageBody.="UserName: ".trim(stripslashes($_POST['username']))."<br />"; 
    $strMessageBody.="Password: ".trim(stripslashes($_POST['pword1']))."<br />"; 
    $strMessageBody.="Re-enter Password: ".trim(stripslashes($_POST['pword2']))."<br />"; 
    echo "<h1>".$strMessage."</h1>"; 
    echo $strMessageBody; 
    } 
} else { 
    $strMessage= "Please fill out the form below to send your information:"; 
    showForm($strMessage); 
} 
+0

私はこの「プロジェクト」を1分間開始してから救済しました。 +1は努力していますが、 'elsif'sをチェックしてください、PHPには' elseif'が必要です –

+0

ありがとう、私は何か間違っていたことを知っていました。 – andy

+0

@Wesley Tnx! 'elsif'sが' elseif'sに変更されました – Jochem

2

1終了}がありません。唯一の問題はどこですか?あなたがそれを前に置くと?>解析エラーは消えてしまいますが、私はこれが確かな場所であるかどうかはわかりません。あなたの難しいロジックに依存します。

+0

コードをもう少し詳しく見ると(私は分かりませんが)、コードそのものの解釈によって、問題は少し深くなります(私の答えを見てください)。 – Jochem