Inserting Into HTML page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
~ Zymus ~
Forum Newbie
Posts: 11
Joined: Wed Nov 05, 2008 8:36 pm

Inserting Into HTML page

Post by ~ Zymus ~ »

Hello,

I am trying to find the most efficient way to change html, depending on whether or not a certain condition is met. I found a way to do it, but im wondering if it is the most efficient way.
Because IMO, it looks messy...

index.php:

Code: Select all

<?php
function GetLoginInfo()
    {
        if(isset($_COOKIE["login"]))
            {
                $LoginInfo = $_COOKIE["login"];
                
                $FirstDiv = strpos($LoginInfo, ":");
                $Type = substr($LoginInfo, -1, 3);
                
                $LastDiv;
                
                if($Type == "off")
                    {
                        $LastDiv = strlen($LoginInfo) - 4;
                    }
                    
                else
                    {
                        $LastDiv = strlen($LoginInfo) - 3;
                    }
                
                $Diff = ($LastDiv - $FirstDiv);
                
                $Name = substr($LoginInfo, 0, $FirstDiv);
                $Pass = substr($LoginInfo, $FirstDiv + 1, $Diff - 1);
                
                return true;
            }
        
        else
            {
                return false;
            }
    }
?>
 
<html>
    <head>
        <title>~ Oraculum ~</title>
        
    </head>
    
    <body>
        <link rel="stylesheet" type="text/css" href="main.css"/>
            <p class="title">
                ~ Oraculum ~
            </p>
            <p class="navigation_bar">
            <a href="home.html">Home Page</a>
            <a href="highscores.html">High Scores</a>
            <?php
                if(GetLoginInfo())
                    {
                        print ('<a href="login.html">Log Out</a>');
                    }
                
                else
                    {
                        print ('<a href="login.html">Log In</a>');
                    }
            ?>
            </p>
            <p class="welcome_screen">
                Welcome to the Official ~ Oraculum ~ Website
                <br>
                As you can see, I am still making the site
                <br>
                It will be much more professional once I finish it
                <br>
                So just hop around a bit, and if you find any
                <br>
                glitches, just email me, and I'll be sure to fix it.
                <br>
                <br>
                ~ Zymus ~
            </p>
        </style>
    </body>
</html>
Post Reply