我的PHP代码未显示任何消息

时间:2018-07-14 10:56:25

标签: php html

这是我的第一个php程序。我的代码未显示错误。但它不会打印任何内容。我的代码有什么问题。我正在尝试修复它,但是它不起作用。该程序应根据用户输入打印出强密码或密码错误。拜托,有人帮帮我。预先感谢。

 <?php
 $variable = "";

 //Bad Words Dictonary


 //Use isset function to check whether a varibale is set or not
 if(isset($_POST['submit']))
 {
 $Badwords=array("test","1234567","help,","password");
 $password=$_POST['password']; //declare new variable password and assign to                user's password
     //if user enter 7 or less character password, the program will warn the user.
     if(strlen($password)<8)
         {
        $variable="Passwrod at least should have 8 or more character";
    }
//else the program will check user's password with badwords dictonary
     else
         {
             if(in_array($password, $Badwords))
                    {
                $variable="Your Password is Bad or not Secure!";
                    }
             else
                    {
                 $variable="Your Password is Strong!!";
                    }
         }
 }
 ?>


 <!DOCTYPE html>
 <html>
 <title> Pasword Checker </title>
 <body>

 <!--Create a input text box for passwrod and a button to trigger the action -->
 <!--Need to use Form Tag as we need password input to check it -->
 <form action="" method="post">
    Enter Your Password To Check: <input type="text" name="password" value="">          <br>
    <input type="submit" value="submit"><br>
 </form>
 <p>
 <div class="variable">
    <?php 
    echo $variable; 
    ?>
 </div>
 </p>
     </body>

 </html>

1 个答案:

答案 0 :(得分:0)

替换您的提交按钮

<input type="submit" value="submit"><br>

使用

<input type="submit" name="submit" value="submit"><br>

您错过了name="submit"