[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
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>