Jump to content

If else different page


adamriley

Recommended Posts

Ok to start with there is a variable called "$username" what i want is to see if the variable is got the value of "ar" which would show a html page but if the username is anything else i would like to "header" the user to a different page using if and else statements

 

 

 

Link to comment
Share on other sites

im new to php and this does not work any reason why not

 

The error i get is "[sat Jan 02 15:53:37 2010] [error] [client 127.0.0.1] PHP Parse error:  syntax error, unexpected '<' in C:\\web\\htdocs\\test1.php on line 6"

 

<?php require_once('common.php');
checkUser();
?>
<?php 
if ($_SESSION['userName'] == 'Adamriley'){
<html>
<head>
<title>adam lee riley</title>
</head>
<body>
</body>
</html>
}else{
<html>
<head>
<title>Nathan warburton</title>
</head>
<body>
</body>
</html>
}
?>

Link to comment
Share on other sites

Actually, just close PHP, output the HTML, then open PHP again:

 

<?php require_once('common.php');
   checkUser();
?>
<?php 
if ($_SESSION['userName'] == 'Adamriley'){
/* CLOSE PHP HERE BECAUSE WE WANT TO OUTPUT HTML */ ?>
<html>
<head>
<title>adam lee riley</title>
</head>
<body>
</body>
</html>
<?php }else{ /* OPEN PHP FOR THE ELSE THEN CLOSE IT FOR HTML AGAIN */ ?>
<html>
<head>
<title>Nathan warburton</title>
</head>
<body>
</body>
</html>
<?php } // OPEN PHP AGAIN FOR THE CLOSING BRACE
?>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.