Page 1 of 1

Inserting Into HTML page

Posted: Sun Nov 09, 2008 2:26 am
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>