Can someone please help me with this simple question? How to limit the size of referrer value to maximum 8 characters? $REFERRER = $_POST['REFERRER']; if ($REFERRER==$name || $REFERRER==$_acct || $REFERRER=="") { $REFERRER = $_def_ref; } PHP: Thank you!
if (strlen($REFERRER) > 8) { echo "You have entered a referrer name longer than 8 characters"; } else { //rest of code. } PHP:
If your looking for a way to limit the length, rather than not allow, like papa_faces's code try: <?php echo substr('$REFERRER', 0, 8); ?> Code (markup): That will only output the first 8 characters.
what i really want is: if referrer is longer than 8 chars then exit script something like that... if ($referrer==0) exit; just instead of 0 i want my 8 chars rule thank you everyone so far is this correct? if (strlen($REFERRER) > 8) exit;
can't i write this without the else code? only like this: if (strlen($REFERRER) > 8) exit; then continue with normal code... OR USE THIS: if ($REFERRER==$name || $REFERRER==$_acct || $REFERRER=="" || strlen($REFERRER) < 8)
Yes you can use just something like this: $REFERRER = $_POST['REFERRER']; if (strlen($REFERRER) > "8") { exit; } // continue script here. Code (markup):