0

i have a question that can we make a dynamic title using php???
is it possible?
i mean the header

4
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by almostbob
0

It is possible. Take a look at the codes below. I have created two pages set.php and title.php.
The set page contains a form where the user enters a title. When user clicks the SET TITLE button, the user input is sent to the title.php page and used as the title for that page.

set.php

<?php
if(!isset($_POST['set_title']))
{
?>
<form method = "post" action = "title.php">
Enter title : 
<input type = "text" size = "50" name = "title">
<input type = "submit" name = "set_title" value = "SET TITLE">
</form>
<?php
}
?>

title.php

<?php
echo "<html>";
echo "<head>";
echo "<title>".$_POST['title']."</title>";
echo "</head>";
echo "<body>";

echo "</body>";
echo "</html>";
?>

Edited by cossay: n/a

0

yes, as in the replies above, the title is just a tag, the tag can be written in php from a datatabase, from any of the parameters passed to the filename, from any php predefined variable, date, time
a search page, links to external sites, and use the title as part of attribution, that the content is somebody else's, the relevant sites use a similar arrangement linking our content
code_sample takes a parameter ext, external.php?ext=(urlencoded url),

<?php if(!$_GET['ext']){ header("Location: /index.php");
exit; }
$ext=$_GET['ext']; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><script type="text/javascript">
function sizer() {
var viewportheight;
 if (typeof window.innerWidth != 'undefined') { viewportheight = window.innerHeight }
else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) { viewportheight = document.documentElement.clientHeight }
else { viewportheight = document.getElementsByTagName('body')[0].clientHeight }
document.getElementById('extern').style.height=viewportheight-26 + 'px';
}
document.onresize = sizer();
</script>
<!--[if IE]>
<script type='text/javascript'>
window.onresize=sizer;
</script>
<![endif]-->
<title>Linking external site <?php echo $ext; ?></title>
<link rel='stylesheet' href='/style.css.php' type="text/css" media='all'>
<script type="text/javascript" src="/script.js.php"></script>
</head><body onload='sizer();' style='margin:0;padding:0;height:100%;text-align:center;'>
<div style='height:23px;width:100%;text-align:center;'>External site &nbsp;<a href='<?php if (isset($_SERVER['HTTP_REFERER'])) {echo $_SERVER['HTTP_REFERER']; }
else {echo "/reload.php";} ?>'>&nbsp;<span class='smalltext'>Return to</span> referring&nbsp;page&nbsp;</a></div>
<iframe name='extern' id='extern' frameborder='0' width='100%' height='200px' src='<?php echo $ext; ?>'>loading frame</iframe></body></html><?php } ?>

I know iframes are tacky and unneccessary, but it works and havent bothered to recode this script for years

Edited by almostbob: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.