porko2004 Posted July 20, 2009 Share Posted July 20, 2009 hi guys im creating a script to change password it all works but i got a problem im trying to add code to see if entered password is more then 10 characters in length this code is in line 50. <body oncontextmenu="return false;"> <body background="../images/other.jpg"> <form action="script.php" method="POST"> <div class="reg_main" style="width: 340; height: 144"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <?php $connection=mysql_connect("localhost","test","test"); $db=mysql_select_db("account_zf",$connection); $result = mysql_query("select password from account where name='$_POST[txtAccount]'"); if(!$result) { echo ' '; die('<center>AccountID does not exist <br> <a href="../modpass">Back</a></center>'); } $row = mysql_fetch_row($result); $accpass = $row[0]; if (!$_POST['txtAccount'] ) { echo ' '; die('<center>You did not fill the Account ID field <br> <a href="chg.php">Back</a></center>'); } else if (!$_POST['password'] ) { echo ' '; die('<center>You did not fill the Password field <br> <a href="chg.php">Back</a></center>'); } else if (!$_POST['txtPassword'] ) { echo ' '; die('<center>You did not fill the New Password field <br> <a href="chg.php">Back</a></center>'); } else if (!$_POST['txtConfirmPassword'] ) { echo ' '; die('<center>You did not fill the Re-type New Password field <br> <a href="chg.php">Back</a></center>'); } else if($_POST['password']!= mysql_result($result, 0)) { echo ' '; die( '<center>Password invalid.<br><a href="chg.php">Back</a></center>'); } else if ($_POST['txtPassword'] == $accpass) { echo ' '; die('<center>This password is the one being used. <br><a href="chg.php">Back</a></center>'); } else if($_POST['txtPassword']!=$_POST['txtConfirmPassword']) { echo ' '; echo "<center>Your passwords don't match.</center>"; echo '<center><a href="chg.php">Back</a></center>'; } else if($_POST['txtPassword']< 10 || $_POST['txtConfirmPassword']< 10 ) { echo ' '; echo "<center>Your new password must be at least 10 characters in length!</center>"; echo '<center><a href="chg.php">Back</a></center>'; } else $sql=mysql_query("UPDATE Account SET password='$_POST[txtPassword]' WHERE name='$_POST[txtAccount]'") or die(mysql_error()); if($sql) { echo ' '; echo '<center>You have successfully changed your password.</center>'; echo '<center><br><br>If there is any login problems please contact us at <a href="mailto:[email protected]">[email protected]</a></center>'; } ?> </tr> </table> <div class="clear"></div> </div> <br /><br /> </form> Thanks Link to comment https://forums.phpfreaks.com/topic/166574-little-question/ Share on other sites More sharing options...
Philip Posted July 20, 2009 Share Posted July 20, 2009 Use strlen() Link to comment https://forums.phpfreaks.com/topic/166574-little-question/#findComment-878377 Share on other sites More sharing options...
porko2004 Posted July 20, 2009 Author Share Posted July 20, 2009 Use strlen() Use strlen() can u show me please by using my code Link to comment https://forums.phpfreaks.com/topic/166574-little-question/#findComment-878380 Share on other sites More sharing options...
Coreye Posted July 20, 2009 Share Posted July 20, 2009 else if(strlen($_POST['txtPassword']) < 10 || strlen($_POST['txtConfirmPassword']) < 10) Link to comment https://forums.phpfreaks.com/topic/166574-little-question/#findComment-878386 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.