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
https://forums.phpfreaks.com/topic/186881-if-else-different-page/
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>
}
?>

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
?>

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.