problem in php function

Hello,

Can any one help me out from php problems.
I have tired to solve this problem but php function is not working in wamp server as well tags are ignored.

can any one look in to this matter…

<blockquote>    <?PHP
require_once("./include/membersite_config.php");
require_once("./include/fg_membersite.php");
if(!$fgmembersite->CheckLogin())
{
$fgmembersite->RedirectToURL("login.php");
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Home page</title>
<link rel="STYLESHEET" type="text/css" href="style/fg_membersite.css">
</head>
<body>
<div class='h1'>
<div class="Top_Logo">
</div>
</div>
<div id='fg_membersite_content'>
<h2>Home Page</h2>
Welcome back
<!-- This is what it ignores, but it uses the php above perfectly fine-->
<?= $fgmembersite->UserFullName(); ?>!
<p><a href='change-pwd.php'>Change password</a></p>
<p><a href='access-controlled.php'>A sample 'members-only' page</a></p>
<br><br><br>
<p><a href='logout.php'>Logout</a></p>
</div>
</body>
</html></blockquote>

Thanks,

I am no PHP expert still learning like you shouldn’t you be setting the header if user not logged in with something like

[php]header(“Location: login.php”);[/php]

If the user isn’t logged in rather than what you have now?

Im no expert either…but ill give it a shot. not sure whats going in in your require_once files, but if you have the username of the current session stored as a variable somewhere, you should change
[php]<?= $fgmembersite->UserFullName(); ?>![/php]
to be something like this
[php]<? Echo $_SESSION["username"] . "!"; ?>[/php]

I would advise against using php short-tags: <?= instead you should use: <?php

Many servers have short tags disabled in their configuration. While there was a time when the short tags were in general use, they have not been recommended for a number of years; as they conflict with XML headers. Since the properly tagged code is executing fine, there is a good chance that this is your problem.

Without knowing the contents of your included files, I can’t say too much regarding the code, but I would try changing the tags and see if that solves the problem.

While you can turn short tags on in your php.ini configuration, I wouldn’t unless you absolutely have to for compatibility with an existing site. If you ever need to migrate to a server that you don’t control, or if short tags ever become depreciated, you will have a lot of work on your hands to get things back up and running.

If this doesn’t solve your problem, we will probably need you to post the code for your $fgmembersite class.
A helpful suggestion: When you post code, use the php button on the formatting bar. This will create two special tags for you to paste your code between. This will put your code in a nice, color-coded scroll box.

Let me know,

jay

Sponsor our Newsletter | Privacy Policy | Terms of Service