-3

This is my very first php program. My code is not showing error. But it doesn't print out anything. What is wrong with my code. I am trying to fix it but it doesn't work. The program should print out Strong password or Bad passwrod according to user input. Please, someone, help me. Thanks in advance.

 <?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>
Vincent
  • 9
  • 6
  • 6
    Your submit button doesn't have a `name="submit"`, so `$_POST['submit']` will never exist. – rickdenhaan Jul 14 '18 at 11:03
  • Checkout your error log in server, there should have hints. Or you can turn on display_errors in php.ini – Jacob Jul 14 '18 at 11:04
  • see this https://stackoverflow.com/questions/7775512/using-ifisset-postsubmit-to-not-display-echo-when-script-is-open-is-not – flyingfox Jul 14 '18 at 11:04
  • @lucumt instead of posting a comment with a link to another question, it's better to flag or close (depending on your reputation) the question as a duplicate. – rickdenhaan Jul 14 '18 at 11:07

1 Answers1

0

Replace your submit button

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

with

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

You have missed name="submit"

sanoj lawrence
  • 951
  • 5
  • 29
  • 69