thefollower Posted January 31, 2008 Share Posted January 31, 2008 For some unknown reason my validation is not working on the string length, not sure what I have done wrong but it just doesn't header out. Have i got the syntax wrong or something? Hope you can help! <?php $MessageText = 0; If(strlen($MessageText) > 255 OR strlen($MessageText) < 10 OR $MessageText == ''){ Header("location: composeletter.php?toolongmessage"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88722-string-length-validation-not-working/ Share on other sites More sharing options...
laffin Posted January 31, 2008 Share Posted January 31, 2008 Your example program worked fine here. Maybe it did error out and u didn;t know it? check apache log for any errors. most likely u got a headers already sent error message. Quote Link to comment https://forums.phpfreaks.com/topic/88722-string-length-validation-not-working/#findComment-454384 Share on other sites More sharing options...
thefollower Posted January 31, 2008 Author Share Posted January 31, 2008 Nah it could not have sent because it continued to do the rest of the script. I got error report on. Ill put a die; after the header to see if that works Quote Link to comment https://forums.phpfreaks.com/topic/88722-string-length-validation-not-working/#findComment-454390 Share on other sites More sharing options...
laffin Posted January 31, 2008 Share Posted January 31, 2008 DOH, Good point, that shudda fixed it for ya Quote Link to comment https://forums.phpfreaks.com/topic/88722-string-length-validation-not-working/#findComment-454392 Share on other sites More sharing options...
revraz Posted January 31, 2008 Share Posted January 31, 2008 You should use a ELSE anyways. <?php $MessageText = 0; If(strlen($MessageText) > 255 OR strlen($MessageText) < 10 OR $MessageText == ''){ echo "False"; } else { echo "True"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88722-string-length-validation-not-working/#findComment-454394 Share on other sites More sharing options...
laffin Posted January 31, 2008 Share Posted January 31, 2008 there is no need for an else. die/exit end the script right there. Quote Link to comment https://forums.phpfreaks.com/topic/88722-string-length-validation-not-working/#findComment-454409 Share on other sites More sharing options...
haku Posted January 31, 2008 Share Posted January 31, 2008 it just doesn't header out. You mean it doesnt forward? Echo something (I usually use echo "here") before the header to confirm that you are even entering that part of the conditional. If you are, then check and make sure you have absolutely NO output to the page before that point (including spaces at the end of include files or what not), as that will prevent the header from working. Those random spaces can be hard to track down... Quote Link to comment https://forums.phpfreaks.com/topic/88722-string-length-validation-not-working/#findComment-454418 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.