I am using wampsever and it allows me to use php function to check if I am logged in but it is ignoring the tags inside of the html which calls a function, here is my code.

<?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>
Member Avatar for LastMitch

@garyjohnson

I am using wampsever and it allows me to use php function to check if I am logged in but it is ignoring the tags inside of the html which calls a function,

May I ask is $fgmembersite a file or just a variable?

In order for an function to work inside of <html>

You have to add <?php?> or <? include(""); ?>

I don't know what is $fgmembersite? So:

For your old code:

<?= $fgmembersite->UserFullName(); ?>!

To your new code:

<?php $fgmembersite->UserFullName(); ?>

this should work.

$fgmembersite is a file, which is located in a sub folder. but when this code was on a hosting site like godaddy it worked fine. When is displays this code on the screen it shows this

UserFullName(); ?>

It disregards these tags <?= $fgmembersite->

If short_open_tags are disabled <?= does not work (before PHP 5.4.0). Check your settings.

That must be the problem, thank you, but how do I call a function if I need to use php 5.2.xx?

LastMitch already showed you how, but missed the echo.

<?= $fgmembersite->UserFullName(); ?>

would become:

<?php echo $fgmembersite->UserFullName(); ?>

So i use this code <? include(" $fgmembersite->UserFullName();"); ?> ?

Member Avatar for LastMitch

@garyjohnson

<? include(" $fgmembersite->UserFullName();"); ?>

that's wrong. May I ask what are you trying to do?

if you used <? include(""); ?> it has to be a file. $fgmembersite is not a file!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.