Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Quick question how to make user use at least 4 characters in password

$
0
0
Hi can someone show me how to make the password requirement on this form to be at least 4 characters I just have no idea I have been trying different ways and none work. I have posted my code below if you could just show me the code up dated with the way to handel this that would be great thanks in advance.
<?php
function printForm($strMessage){
echo "<strong>" .$strMessage."</strong>";
echo "<form method=\"post\" action=\"" .$_SERVER['PHP_SELF']. "\" name=\"form\">\n<br>";
echo "Your Name: <input type=\"text\" Name=\"yname\" value=\"" .trim($_POST['yname'])."\"><br>";
echo "Your Email: <input type=\"text\" Name=\"yemail\" value=\"" .trim($_POST['yemail'])."\"><br>";
echo "Username: <input type=\"text\" Name=\"yusername\" value=\"" .trim($_POST['yusername'])."\"><br>";
echo "Password: <input type=\"password\" Name=\"pword\" value=\"" .trim($_POST['pword'])."\"><br>";
echo "Confirm Password: <input type=\"password\" Name=\"cpword\" value=\"" .trim($_POST['cpword'])."\"><br>";


echo "<input type=\"submit\" value=\"send\" Name=\"submit\"/>\n<br>";
echo "</form>\n";
}
?>
<html>
<head>
<title>Self Submitting Sticky Form</title>
</head>
<body>
    <?php
    if(isset($_POST['submit'])){
        $yourname=trim($_POST['yname']);
        $youremail=trim($_POST['yemail']);
        $yourusername=trim($_POST['yusername']);
		$yourpassword=trim($_POST['pword']);
        $yourcpassword=trim($_POST['cpword']);


       if ($yourname==''){
        $strMessage='Please enter your name.';
        printForm($strMessage);
        }
        elseif ($youremail==''){
		        $strMessage='Please enter your email.';
		        printForm($strMessage);
        }
        elseif ($yourusername==''){
				        $strMessage='Please enter your username.';
				        printForm($strMessage);
        }
        elseif ($yourpassword==''){
				        $strMessage='Please enter your password.';
				        printForm($strMessage);
        }
        elseif ($yourcpassword==''){
				        $strMessage='Please confirm your password.';
				        printForm($strMessage);
        }
        elseif ($yourcpassword != $yourpassword){
				        $strMessage='passwords must match.';
				        printForm($strMessage);
        }



        else{
        $strMessage='Thank you. your information was sent.';
        echo $strMessage;
        }
     }
     else{
     $strMessage='Please enter all fields below:';
     printForm($strMessage);
     }
     ?>
     </body>
     </html>

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>