| | |
Specifying page title while using this script.. :(
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2008
Posts: 1
Reputation:
Solved Threads: 0
Hi All, i'm new here but hoping someone can give me some much needed help! 
I'm new to PHP Completely, the script i currently use to pull pages for this website is something i borrowed from a freind.
I Kinda understand this one script, but the rest is unknown to me... so heres my issue.
This script pulls the pages when a user clicks a link
Now, i specify the page title in the main index.php file, but that then means i can't change the page title by what page the user is going on
Example, on home.php (default) the page title is set to Home. If i put it on about, its still home even if in the about.php i set the title to About.
Please help if you can, i'd be very greatful!

I'm new to PHP Completely, the script i currently use to pull pages for this website is something i borrowed from a freind.
I Kinda understand this one script, but the rest is unknown to me... so heres my issue.
This script pulls the pages when a user clicks a link
PHP Syntax (Toggle Plain Text)
if (file_exists("./pages/$_GET[act].php")) { if (!preg_match("/^(http|https|ftp)\:\/\//i", $_GET[act])) { require("./pages/$_GET[act].php"); } } else { require("./pages/home.php"); }
Now, i specify the page title in the main index.php file, but that then means i can't change the page title by what page the user is going on

Example, on home.php (default) the page title is set to Home. If i put it on about, its still home even if in the about.php i set the title to About.
Please help if you can, i'd be very greatful!
I'm afraid you're not giving the full story here.
Is this script is embedded in a HTML document that has the Home title?
And you need to include (using require()) a part of this HTML document, right?
If my guesses are right then:
You cannot have two TITLE tags in one HTML document - there can only be one and it must be in HEAD (HEAD is at the very beginning of a HTML document). That's why you cannot use TITLE later on in the included file that comes into BODY part of the parent document.
The quick'n'dirty solution is to use JavaScript to change the title.
This is just for the user though, search engines won't see it, they will still read the original value (Home).
Is this script is embedded in a HTML document that has the Home title?
And you need to include (using require()) a part of this HTML document, right?
If my guesses are right then:
You cannot have two TITLE tags in one HTML document - there can only be one and it must be in HEAD (HEAD is at the very beginning of a HTML document). That's why you cannot use TITLE later on in the included file that comes into BODY part of the parent document.
The quick'n'dirty solution is to use JavaScript to change the title.
html Syntax (Toggle Plain Text)
<script language="JavaScript"> document.title = 'new title'; </script>
Petr 'PePa' Pavel
The more information you give the more relevant answer you get.
Please consider using "Add to ... Reputation" and mark your thread as Solved if you found what you were looking for. By giving feedback you help others.
The more information you give the more relevant answer you get.
Please consider using "Add to ... Reputation" and mark your thread as Solved if you found what you were looking for. By giving feedback you help others.
•
•
Join Date: Aug 2008
Posts: 381
Reputation:
Solved Threads: 33
You might try using this at the very top of you page ...
and including the results of this in your title ...
or passing additional values along with your $_GET['act'] value ...
Cheers
and including the results of this in your title ...
or passing additional values along with your $_GET['act'] value ...
PHP Syntax (Toggle Plain Text)
<?php $act = $_GET['act']; if ( file_exists( "./pages/$act.php" ) ) { if ( !preg_match( "/^(http|https|ftp)\:\/\//i", $act ) ) { require( "./pages/$act.php" ); $title = ucfirst( $act ); } } else { require("./pages/home.php"); $title = 'Home'; } ?> <html> <head> <title><? print $title ?></title> </head> <body> ... </body> </html>
Cheers
Google is the answer to all of your questions -- the trick is knowing what question to ask in your specific predicament.
![]() |
Similar Threads
- Send a text message to your phone from your site! (ColdFusion)
- need help with url rotator script (HTML and CSS)
- Dual use of <asp:TextBox in ASP.NET page (JavaScript / DHTML / AJAX)
- how can i createa slide show in aspx page (ASP.NET)
- Regarding: Pass one to Another Page values with coding enclosed (PHP)
- simple ajax script problem (JavaScript / DHTML / AJAX)
- problem in javascript coding in asp page (ASP)
- Error message when running ASP email script (ASP)
Other Threads in the PHP Forum
- Previous Thread: Help with preg_match
- Next Thread: php eway implemntation help need
Views: 581 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access activation ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem procedure query radio ram random recursion regex remote script search select server sessions smash sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web websitecontactform xml youtube





