PHP读取错误

发布于 2024-11-16 10:24:18 字数 2513 浏览 0 评论 0原文

是的,我相信我已经完成了此操作,但我收到一条消息,上面写着“解析错误:解析错误,第 106 行 C:\wamp\www\contactform.php 中意外的 $end”。我俯视该行。唯一的想法我能想到的是,else、elseif 和 if 是错误的,我一直在尝试将它们互换,看看是否会有所不同。但到目前为止还没有任何进展。

    </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>

Yes I believe I have this done but I am getting a message that is saying Parse error: parse error, unexpected $end in C:\wamp\www\contactform.php on line 106. I look down on that line.The only think I can think of is that the else, elseif and if are wrong i been trying to switch them around to see if that makes a different. But nothing so far.

    </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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一念一轮回 2024-11-23 10:24:18

我相信这就是你想要的。您已经重复“if (isset($_POST['submit'])){”两次太多了!

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);
}

I believe this is what you want. You have been repeating the "if (isset($_POST['submit'])){" two times too many!

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);
}
故事↓在人 2024-11-23 10:24:18

缺少一个结尾}。唯一的问题是在哪里?如果你把它放在前面?>解析错误将会消失,但我不确定这是一个合适的地方。取决于你的困难逻辑。

one closing } is missing. the only question is where? if you put it before ?> the parse error will disappear, but i'm not sure this is apropieate place. depends on your difficult logic.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文