Results 1 to 2 of 2

Thread: [RESOLVED] Set Title (After It's Been Set)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2007
    Location
    Rochester, NY
    Posts
    111

    Resolved [RESOLVED] Set Title (After It's Been Set)

    Quick simple question, which may seem easy to those that write scripting languages, I'm not very familiar with php. I need to know how to set the title of a page after it's already been set.

    Example. Page sets to 'This is your page'. It checks to make sure that the user is logged in, if so page title changes to 'Welcome (user)'. I have provided a portion of the script as is to this moment.

    PHP Code:
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
            <link rel="stylesheet" href="style.css" type="text/css">
            <title>This Is Your Page</title>
        </head>

    <?php
    if($_SESSION['valid'])
    {

        
    $username     $_SESSION['username'];
        
    $get             $_GET['do'];
        
        switch(
    $get)
        {
            
            default:
            
                
    $sql mysql_query(sprintf("SELECT * FROM `users` WHERE `username` = '$s'"$username)) 
                or die(
    'Error: ' mysql_error());

                
    ?>

                    <table width="500" cellpadding="0" cellspacing="0" class="mainBody" align="center">
                        <tr>
                            <td align="center" class="headTitle">
                                <u><?=$username;?>'s Account</u>
                            </td>
                        </tr>
                    </table>
    I removed the database for obvious reasons, but this is the jest of it. Thanks in advance
    Please use the search function prior to posting a question and see if someone's already answered it.
    -If I helped you, please rate me, as I'd do the same for you =)
    -Remember to select the Resolved option for your post when you've gotten the answers you need.

  2. #2
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: Set Title (After It's Been Set)

    I can't really see how you're using it, but shouldn't javascript work for this?

    If I'm wrong, you can still give the title a variable and preset that variable with the default title.

    PHP Code:
    <?php
    $title 
    'default title';
    if(
    $something == true){
       
    $title 'something';
    }
    ?>
    <html>
    <head>
    <title><? echo $title; ?></title>
    </head>
    Delete it. They just clutter threads anyway.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width