Page 1 of 1

simple php if question

Posted: Sun Mar 21, 2004 1:12 pm
by jacka18l
<?
$data=$_POST[data];
//then from here i want like it so that it checks and if you post from
//and if data is over 5 characters long then it will take you to yes.html
//and if it is 5 or less characters then take you to no.html
?>
<?
echo "";
?>

that is from a post form.

please help me a.s.a.p as i need this pretty urgently and i am not greaty with php. thanks

contact me on aim = jacka18l
or email = jack@parryspad.freeserve.co.uk

Posted: Sun Mar 21, 2004 1:38 pm
by coreycollins

Posted: Sun Mar 21, 2004 1:46 pm
by jacka18l
i am such a stupid php noob. can someone please write this for me please?

Posted: Sun Mar 21, 2004 1:49 pm
by tim
if you looked at that above link, you'd see who simple it was. least make an effort :x

Code: Select all

<?php
$data=$_POST['data']; 
$num = strlen($data);

if ($num >= 5 ) {
//no.html
} else {
// yes.html
)

?>

Posted: Sun Mar 21, 2004 1:49 pm
by coreycollins
We're not really here to right stuff for you, we're here to help you learn php... Just think about it. I'll give you an example:

Code: Select all

if (strlen($data) >= 5)
{
    // do stuff
}
elseif (strlen($data) < 5)
{
    // do stuff
}
I didn't test this so it may have an error...

lol Tim beat me to it

Posted: Sun Mar 21, 2004 1:52 pm
by tim
lol mine had a few errors in it

you'll have that.

Posted: Sun Mar 21, 2004 3:43 pm
by jacka18l
thanks for all your help