Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    validation giving me nothing whEn program runs

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Password Strength</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    </head>
    <body>
    <?php
    $password = array( 
                    "12?b5A", 
                    "A234567?", 
                    "aBcdefg?", 
                    "Mno edf1?", 
                    "abcde1?n", 
                    "Sasuke!Naruto9", 
                    "Anime_Rules!", 
                    "Fairy_Tail2", 
                    "Natsu_dragoneal1"); 
    foreach {($password as $Passwordchk)	
    if( strlen($Passwordchk) < 8 ) {
    	$error .= "Password too short! 
    ";
    }
    
    if( !preg_match("#[0-9]+#", $Passwordchk) ) {
    	$error .= "Password must include at least one number! 
    ";
    }
    
    
    if( !preg_match("#[a-z]+#", $Passwordchk) ) {
    	$error .= "Password must include at least one letter! 
    ";
    }
    
    
    if( !preg_match("#[A-Z]+#", $Passwordchk) ) {
    	$error .= "Password must include at least one CAPS! 
    ";
    }
    
    
    
    if( !preg_match("#\W+#", $Passwordchk) ) {
    	$error .= "Password must include at least one symbol! 
    ";
    }
    
    
    if($error){
    	echo "Your password is invalid: $error";
    } else {
    	echo "Your password is strong.";
    }
    }
    ?>
    </body>
    </html>

    This is am assignment I have to do to validate passwords. I have to have an array that includes at least 10 passwords and six of those must fail. I have to use regular expressions and the passwords must test to be at least 8 characters, include one uppercase, one lower case, one number and one character that is not a letter. It can also not have any spaces. I have to display if each one is strong enough and display the errors. This is what I have so far but it displays nothing. I am not sure what I have done wrong. I also do not have the code to test for spaces included yet...Could someone point me in the right direction with this...I think I may have an issue with my brackets but I have stared at this so long and now I am cross eyed . thanks

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Displaying no source is an indication of parser errors. Ensure you specify your php.ini is configured with error_reporting enabled.
    The foreach is a prime example. It is syntactically incorrect since the opening brace is in the incorrect location.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,036
    Thanks
    23
    Thanked 589 Times in 588 Posts
    Definitely make sure error_reporting is enabled. I ran your code and got the error that Fou-Lu stated on line 20. Also include
    PHP Code:
    $error ''
    or that will give an error. And think about some <br /> s in the error messages.
    Evolution - The non-random survival of random variants.

  • #4
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am using notepad++ to create this . I s there a better program to use? It doesn't give me errors so I have to guess why my program is not running. It is very frustrating. I fixed my braces in my foreach statement so that it is in the right place .

  • #5
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,036
    Thanks
    23
    Thanked 589 Times in 588 Posts
    I run WAMP to run my php. Errors should show up in your browser, makes no difference what your editor is.
    Evolution - The non-random survival of random variants.

  • #6
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,281
    Thanks
    57
    Thanked 523 Times in 510 Posts
    Blog Entries
    5
    Quote Originally Posted by tazzy0429 View Post
    I am using notepad++ to create this . I s there a better program to use? It doesn't give me errors so I have to guess why my program is not running. It is very frustrating. I fixed my braces in my foreach statement so that it is in the right place .
    Notepad++ is fine for editing the php files but it will not RUN php files. Those are accessed via a webserver which invokes php to run the php code within the script.

    If you do not have a webserver for testing, download a wamp package such as wamp, uniform server, xamp etc.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •