Danny620 Posted July 13, 2009 Share Posted July 13, 2009 why is it that when enter something in my text box it does not vailidate it and it gets passed <?php require_once('access/mysqli_connect.php'); //Function val validates form submissions by; //Striping html tags from from; //Must be greater than three letters long; function val($field = false){ global $dbc; $errors = false; if(strlen($field) > 3 && strlen($field) < 15){ strip_tags($field); trim($field); htmlentities($field); $username = $field; $username = mysqli_real_escape_string($dbc,$username); echo $username; } else { $errors = "The field must be at least 3 characters long & no more than 15 characters!"; } if($errors){ return $errors; } } //END of val function; ?> heres the code for the form <?php include('val.php');?> <?php if(isset($_POST['sub'])){ $user = $_POST['username']; $suser = val($user); } ?> <form name="form1" method="post" action=""> <label> <input name="username" type="text" id="username" value="<?php if (isset($suser)){ echo $suser; } ?>"> </label> <p> <input name="sub" type="hidden" id="sub" value="TRUE"> </p> <p> <label> <input type="submit" name="send" id="send" value="send"> </label> </p> </form> Quote Link to comment https://forums.phpfreaks.com/topic/165814-getting-passed-my-valaidation/ Share on other sites More sharing options...
ignace Posted July 13, 2009 Share Posted July 13, 2009 function val($field = false) { global $dbc; $errors = false; $strlen = strlen($field); if($strlen > 3 && $strlen < 15) { $field = strip_tags($field); $field = trim($field); $field = htmlentities($field); $username = $field; $username = mysqli_real_escape_string($dbc,$username); echo $username; } else { $errors = "The field must be at least 3 characters long & no more than 15 characters!"; } if($errors) { return $errors; } } Try this and behold the magic of proper indentiation. Quote Link to comment https://forums.phpfreaks.com/topic/165814-getting-passed-my-valaidation/#findComment-874620 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.