brent123456 Posted June 22, 2007 Share Posted June 22, 2007 I have a javascript function set up to check characters as they are being typed. I was wondering how I would check the $_POST[foo] variable to make sure that it is less then say 50 character on submit in case javascript is turned off? Thanks Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 22, 2007 Share Posted June 22, 2007 <?php if (strlen($_POST['foo'] > 50)){ echo "Foo is too long!"; } else { echo "Foo is a good length....continue."; } ?> Quote Link to comment Share on other sites More sharing options...
brent123456 Posted June 22, 2007 Author Share Posted June 22, 2007 thank you Quote Link to comment Share on other sites More sharing options...
brent123456 Posted June 23, 2007 Author Share Posted June 23, 2007 if (stripslashes(trim($_POST['discription']) && (strlen($_POST['discription'] < 75)))) { $d = escape_data($_POST['discription']); print strlen($_POST['discription']) ; } else { $d = false; echo '<p><font color="red" size="+1">Please enter your Feedback!</font></p>'; } This doesn't seem to be validating is there something wrong with my code? Even when $_POST['discription'] is more then 75 characters it is not going to the else option. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 23, 2007 Share Posted June 23, 2007 Try this: <?php $description = stripslashes(trim($_POST['discription'])); if (strlen($description) < 75) { //If description is LESS than 75 chars $d = escape_data($description); //I'm assuming escape_data() is a function you wrote? print strlen($description); } else { //Do this if description is MORE than 75 chars $d = false; echo '<p><font color="red" size="+1">Please enter your Feedback!</font></p>'; } ?> Quote Link to comment 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.