hi there

am trying to create a welcome page for when a member register/login but i dont quite know where the error is. i know there is an error there somewhere but as usual, finding my errors in one of my major fault. I am doing it in php

the opening tag in php is red as it supposed to be but the closing tag is black which is not supposed to be among other codes in the form

I put it in a html form but it is saved as a php. the closing tag of the body and html element are black in color which i dont think it should be. it should be blue but somewhere in the codes is an error, can someone explain to me why it is like that. trying looking through the codes but cant find it, i even past it thru a php validator.

here is the codes that I have tried.

<?php

    session_start();

    if(isset($_SESSION['user']))
    {
        header('Location:login.php');
    }

?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"

"http://www.w3.org/TR/xhtml11.dtd">

<html xmlns="http:www.w3.org/1999/xhtml"xml:lang="en" lang="en">

    <head>
        <title> Welcome - <?php echo <$_SESSION['user']; ?></title>
    </head>
    <body>

        <?php

            <h2> Welcome!!!</h2>

            <option value="realname"><?php echo $_SESSION['firstname']. ' ' .$_SESSION['lastname']?></option>

        ?>

    </body>
</html>

hi guys

just want to let you all know I have since figure out the answer, I kinda change it up so it is looking like the way I hope it should look to the answer above

what I would like to know now: how do you create a link from a html file to a php file, is it the same as <a href="welcome.php"> welcome.php</a> or is it something else

or what is another way of doing it. I am trying to create a link from a html file to go to a php file.

your href tag doesn't care what type of page you're going to as long as the page exists
<a href="any/valid/url">something to click on(text/image)</a>

That because you did this in the wrong way, you can't expect php to execute html code you need to echo it. The problem is here <h2> Welcome!!!</h2> <option value="realname"><?php echo $_SESSION['firstname']. ' ' .$_SESSION['lastname']?></option> you need to echo that something like this echo "<h2> Welcome !!!</h2>"; echo "<option value='realname'> .$_SESSION['firstname']. ' ' .$_SESSION['lastname']. </option>"; Something like that will solve your problem, didn't test this code but if there is any problem it will be within the SESSIONs so if you get error try to play around with displaying session in that syntex.

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.