php code

They have: 10 posts

Joined: Aug 2005

Hi
I was wondering what the php code would be for this particular control structure:

if (condition satisfied)
{ open one html page
}

else
{ open another html page
}

any ideas? is it possible?
thanks

Busy's picture

He has: 6,151 posts

Joined: May 2001

An IF ELSE is just that, "do this, IF is ok. ELSE do the other"

$today_is = 'weekend';

if ($today_is == 'weekday')
{
echo 'back to work';
}else{
echo 'woohooo it's the weekend, love these one day work weeks';
}

This is basic PHP, you should really have a read over the manual (php.net)

They have: 14 posts

Joined: Oct 2005

To do a regular redirect, the "open one html page" code might be something like:

header("Location: http://mydomain.com/mypage.html");

Remember that this command must be issued before ANY html is sent out (even blank lines!).

They have: 35 posts

Joined: Jun 2004

Or simply use the include function

if (condition satisfied)
{
include ("/path/to/page");
}
else
{
include ("/path/to/the/other/page");
}
'

They have: 10 posts

Joined: Aug 2005

thanks...i'll try it out

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.