simple php if question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jacka18l
Forum Newbie
Posts: 6
Joined: Sun Mar 21, 2004 1:12 pm

simple php if question

Post 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
coreycollins
Forum Commoner
Posts: 67
Joined: Sun Feb 01, 2004 1:04 pm
Location: Michigan

Post by coreycollins »

jacka18l
Forum Newbie
Posts: 6
Joined: Sun Mar 21, 2004 1:12 pm

Post by jacka18l »

i am such a stupid php noob. can someone please write this for me please?
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post 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
)

?>
Last edited by tim on Sun Mar 21, 2004 1:51 pm, edited 2 times in total.
coreycollins
Forum Commoner
Posts: 67
Joined: Sun Feb 01, 2004 1:04 pm
Location: Michigan

Post 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
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

lol mine had a few errors in it

you'll have that.
jacka18l
Forum Newbie
Posts: 6
Joined: Sun Mar 21, 2004 1:12 pm

Post by jacka18l »

thanks for all your help
Post Reply