Am Creating a login Script and i do not want users to put in number or alpha numeric characters in the username field and i use the the ctype_alnum function the problem is that the validation is also affecting the password field below is login script.
<div id="login"> <?php if(isset($_POST["login"])&&(empty($_POST["username"])||empty($_POST["password"]))) { echo"<p class='style1' style='background:yellow;' > Please You Have to Provide a Valid Username and password</p>"; $staff=false;}?> <form action="<?php $_SERVER["PHP_SELF"] ?>" method="post"> <label style="font-style:bold;color:#FF9900;" ><h2>UserName:</h2> </label> <?php if(isset($_POST["login"])&&(empty($_POST["username"]))) { echo"Your User Name is Required";$staff=false; } elseif(ctype_alnum($_POST["username"])==true) { echo"You are allowed to put in Numbers<br>"; $staff=false; } ?> <input size="40" type="text" name="username" placeholder="UserName"/><br><br> <label style="font-style:bold;color:#FF9900;" ><h2>Password:</h2> </label> <?php if(isset($_POST["login"])&&(empty($_POST["password"]))) { echo"Your Password is Required";$staff=false; } ?> <input style="radius:6;" size="40" type="password" placeholder="Password" name="password"/><br></div> <input type="submit" width="25px" value="Login" name="login"/> </form>
so please help check the code for errors and how to limit the ctype_alnum validation to just the username field.