Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Changing Title Of Page


does anyone know how to use PHP to change the title of a page?

Let's say my title is currently "GOGOGO" , but I want to add a string "$x" to it

so it says "GOGOGO $x", using PHP does anyone know how to do that?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Page Title
I have another post on here for this problem but I think I have overcomplicated the matter.. Ok in it's simplest form: Is there a way to retrieve the current page title and place it into a PHP variable?

something like"

$pagetitle = **** Title of the current page I'm viewing ****

How To Get Page Title, In Not An Easy Way
ok, here is the situation

i have included header.php into index file but
i have this in index.php:
[php]
switch($_GET['action']) {
case 'page':
$pages[0] = "news0.php";
$pages[1] = "news1.php";
.
.

if ($_GET['page'] != "") {
$to_include = $_GET['page'];
include ($pages[$to_include]);
}
break;
default:
include("news.php");
[php]


i tried all sort off stuff like implode, pregmatch,ordinary passing $title variable, $_PHPSELF, and nothing seems to be working.

all i want to do is to get title like domain.com-news.

can anybody give me a tip what should i do?

Can I Change The Title Of A Page
Maybe this is a stupid question, but is it possible to randomly change the title of a page with PHP?

Page Title Into Database
i am trying to make a script that will get the title of a page amd add it to a database.
PHP Code:

Setting The Page Title
I want all of my web pages to look like this

<?php $title = 'My site'
include('http://mySite.com/layout/page_begin.php'); ?>
.... HTML of page body goes here
<?php include('http://mySite.com/layout/page_end.php'); ?>

But, I can't even get the first bit working :-(

here is page_begin.php

<META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=ISO-8859-1">
<link type="text/css" rel="stylesheet" href="/layout.css">
<HTML>
<HEAD>
<TITLE>' <?php print $title ?> '</TITLE>
</HEAD>
<BODY>

The $title evaluates to an empty string - what obvious thing am I
overlooking? I thought that include would inline the php file, thus
making $title available.

Obtaining Page Title
I was wondering if someone could tell me the easiest way to obtaining the page title of a specific url? I've tried to use fopen and those functions but I got the below error.

QuoteWarning: fopen() [function.fopen]: URL file-access is disabled in the server configuration in /home/web/ute.php on line 2

Getting The Page Title For The Sub Menu?
how I could get the page title for the sub menu? I have been working on this one for hours and am getting nowhere. How can I make my php code display the syntax highlighting? I have forgotten. Code:

Page <title> From Include Variable?
I have something like this:

<title><?php print($pagetitle); ?></title>
<body>
<?php include("folders/my_include.php"); ?>
</body>
</html>

and my_include.php contains the value to the variable ($pagetitle). How do I
get the value before the code for the <title> is written. This is just a
basic example I used to try and put across my question, my site has a whole
bunch of includes dynamically generated from user input. I'd just like to
get the <title> to change according to a variable in the includes......but
Im stuck?

I should say also that all my includes have includes themselves, they
include a html template. So placing <?php include("folders/my_include.php");
?> before the title tag won't look very good :)

PHP To Grab Page TITLE And Check For 404 Help
I am looking for a way to pull the <TITLE> from a web page. Does anyone know
a PHP routine or method that can help?

Also, I am looking for a way to test if a page is active. The ping returns
the website is there (But also returns true on a 404 error), But I want to
know if a page is "dead" (404 or other error) or active.

How To Extract A Page Title From An HTML File
I am trying to extract the page title, description and keywords from an HTML page. Description and Keywords are easy, using get_meta_tags().

How To Dynamically Change Page Title Using Php And Require_once?
This is an elementary question, but I've not been able to find the
answer, so here goes:

I am developing a site using php. I have the html header information
in a file that I include in all the pages using the require_once
function.

That is, each page includes the line

<?require_once('PageStart.php')?>

The PageStart.php file essentially defines the header. Omitting the
boring stuff, it's laid out like so:

<html>
<head>
<title>The Title of the Page</title>
<?require_once('styles/PageStyles.css')?>
</head>

<boring stuff snipped>

This works great. The only complaint I have is that there are LOTS of
pages on the site, and using this approach means that every page is
titled "The Title of the Page" When scanning my browser history, I
could have surfed to 30 different pages in the site and they all have
the same title. Makes it hard to know which page I'd like to go back
to.

I'd like to have a way to pass a (sometimes) dynamically generated
page title to the PageStart.php file. I say sometimes because certain
pages (the Main one for example) will always have the same title, so
that could be passed statically. There is another series of pages in
which the same php file accesses a MySQL database to display
information about various family members, and I'd like that title to
be generated dynamically (for example, "All about Mary" or "All about
Ted" depending on the person being described in the page).

Now I KNOW that with php there's a way to do this. I just can't find
it.

$title Not Displaying In <title>$title</title>
For some reason $title will not display in the <title></title> using print or echo. I've tried modifying the if staments to ifelse, and even fiddled with $_GET to get this working. Tried dbl/single quotes, even changed the variable around thinking $title might be a global. nothing working yet. Any ideas?

<?php
$page == 'home'
$title == "Welcome!";
if ($page == 'home') { $title == "Welcome!"; }
elseif ($page == 'about') { $title == "about us"; }
elseif ($page == 'products') { $title == "Products"; }
elseif ($page == 'services') { $title == "Services"; }
elseif ($page == 'repair') { $title == "Upgrades & Repairs"; }
elseif ($page == 'network') { $title == "Network Solutions"; }
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>My Site - <?php print "$title";?></title>
</head>
<body bgcolor="#FFE0C1">
...

Changing Db Within Page
I have a php page that flips between dbs and sometimes it works and sometimes it doesn't... e.g. the first query runs from this db, the second query runs from a different db and then the third query runs from the first db again... the first query will run, the second query will run, but then the third query will not.

Each time that I switch to a query that calls a different db, I used include_once "db_whatever"; before the query, thinking that, that would work, but it doesn't... Is there something I need to do to kill the previous db connection prior to moving onto another one?

Changing Password From Web Page
I have a need to allow a 'email only' user to change their password on the system from my home page. Normally the user does not log in.

1) need them to login to confirm user/pass
2) enable them to change pass using the _passwd_ file.
Since Apache runs as nobody I need a funtion or two to do the above.
NOT using a sql database but just the usual _passwd_ file. using Linix - RH6.0 - Apache with php3_mod I don't mind doing the reading if I know what to read!

Changing Text On Page Via Dropdown Box.
I have a webpage that draws various text decriptions from a mySql database. The description displayed on the page is controlled via a dropdown box. Currently I am using Javascript with a dropdown box (onChange handler) to change the value of a textbox.

Can anybody think of a way that I don't have to use a textbox(with its' scrollbars and background)? How can I change the value of a php variable by changing the selected index of a dropdown box?

Changing The Variable As You Pass It Through To The 2nd Page
I am using a form to push variables through to another page. In the form, (a drop down), the code is:

<select name="1"><option>L</option><option>P</option></select>

Now on the second page I could display the P or the L by saying <?php echo $1 ?> which is fine. What I want is, if someone selects P then it prints 1 on the next page and if they select L then it prints 2. Is this possible?

Changing A More Link Into Page Numbers
I have the following code which I've tried to edit to fit some examples others have posted on here, with no luck. I have a page that displays More and Prev links but not the page numbers. How can I change this code to have page numbers instead of the More Prev? PHP Code:

Access A Secure Page By Changing The Url
how can i stop people getting into a secure logged in page by just typing
www.somesite.co.uk/admin/index.php.

theres a login set up, but i can bypass it by just entering the url location, this is a major security issue that i need to solve relatively quickly before i publish the pages.

what i need/want is if someone isn't logged in it just goes to a page saying "you must be logged in to access this page" then prompts them to login.php.

Changing Titles Per Page With Inc Files.
The way my script is set up now, I have an index.php which calls on inc files.  The problem is that each page (inc file) is using the title set in the php.index.

My goal is to have a title for each page.  I've looked and looked but can't find anything. 

Changing An If Statement To Html Page
How do I change the following code from my process page to a new page with the detials on it. I made a html page cut and pasted it into this spot but it did not work. What do I need to change in order for it to be a html page is shows. Code:

Changing Pictures On Index-page When Reloading
I am a beginner but quite curious anyway.

My problem: I have seen websites that show different pictures whenever you enter the site. By doing this, the sites look always fresh and attractive and I like the idea a lot. Now I like to have the same function on my site but I do not know how that works...

Is there anybody who can give a good "explanation for dummies" on how to do that?

I Need Information From To ......
I have to retrive the title tag information? can you tell me. i
am new to the php ........

can you give the example to get the information between <title> to </title> from the web page...... how shall i get it.

Convert ##TITLE## To $title
Im half way through making an article manager for a new site im launching. If i type ##TITLE## into a text box, when i display the artcile, how do i turn the placeholder ##TITLE## into $title of the article.

i looked at str_replace but i dont think thats what i need... i need something that searched through the text of a var and if it finds anything within ##*## to convert the * into the $var.

Get Title?
How do you get the title of a(n) external webpage? Ive seen it done on the vBulletin's software. Anyone know how to exactly do this? Or is there a PHP function already added to the PHP software that I don't know about.

How Can I Show A Title?
The script below is from a popup window that I have that displays projects, what I would like, is that the title of the window have the project title in it, Code:

Dates In Title?>
Would it go something like this

<title>Title <?php date('Y') ;?> </title>

to get the year in the title or isnt it possible?

Title Case
I haven't found a way to set title case in PHP... IE:

test tItle => Test Title

Is there a way to achieve this?

Title Replace Problem
Here is some of my upload code i am using but i am having problems trying to insert the title into the database, the first is with spaces allowed and the second is without spaces and filled with _ instead, but it wont do it.

I have this a value called $title and this is the title a user gives their submission, and i want to rename the file the same as the title but with the spaces replaced with _ u following me?

I have done it do it does this but when it inserts the title into the database, the spaces are replaces with the _ instead of leaving it alone.

Dynamic Title Issues > Help Please!
Here is my problem: First, I am talking about two files. page.php which serves as the main content page and header.php which contains the obvious header information.

page.php contains the code listed below. I am I am trying to get the <title></title> tag to echo the headline which is described below. The only way of doing this that I have found is copying all of the data below into the head file and placing the <?php echo "?> data into the <title> </title> tags.

That works like a charm! The only problem is I am running into duplicate scripts running which then causes the body (page.php) not to show up. Dynamic titles work fine. Any ideas? Suggestions? Help! Thanks.

<?php
if (!isset($_REQUEST['page'])&&!isset($_REQUEST['story']))
{
header('Location: index.php');
exit;
}

$page = $_REQUEST['page'];
$story = intval($_REQUEST['story']);

include_once('db_fns.php');
include_once('header.php');

$handle = db_connect();
if($story)
{
$query = "select * from stories
where id = '$story' and
published is not null";
}
else
{
$query = "select * from stories
where page = '$page' and
published is not null
order by published desc";
}
$result = $handle->query($query);

while ($story = $result->fetch_assoc())
{
// title
$title = 'Hello!'
// headline
$id = $story['id'];
echo "<a href='page.php?story=$id'><h2>{$story['headline']}</h2></a>";
//picture
if ($story['picture'])
{
echo '<div style="float:right; margin:0px 0px 6px 6px;">'
echo '<img src="resize_image.php?image='
echo urlencode($story[picture]);
echo '&max_width=200&max_height=120" align = right/></div>'
}
// byline
$w = get_writer_record($story['writer']);
echo '<br /><p class="byline">'
echo $w[full_name].', '
echo date('M d, H:i', $story['modified']);
echo '</p>'
// main text
echo $story['story_text'];
}
include_once('footer.php');
?>

Pulling Title Tag Out Of HTML
Is there a simple piece of php code(s) that can pull the title of a
web page out? We need to pull the words in between <title></titleand
insert it into stumble upon. Here is what their requirements are:

META And TITLE Tags?
I have a bunch of pages, all of which use a common interface. Thus, the site is ideal for implementing some kind of template using the include() function. I want all my pages to look something like the following: PHP Code:

Puttin Title And Body Into One
I have a field for title/intro and then the main body. Is it possible to put them all together into $post so that I can search thru all of the article instead of just the main body, or how else could I do this. I am wokrin off this tutorial:

http://www.phpbuilder.com/columns/c...421.php3?page=2

Retrieve <TITLE> In Php Code ?
Simple question, but headache !

I have a PHP Page like :

<HTML>
<HEAD>
<TITLE>Sunny day !</TITLE>
</HEAD>
<BODY>
<?
echo "The title of this page please (Sunny Day !)"
?>
</BODY>
</HTML>

I think that you have understanding my problem : How to retrieve the
title of my page ?

How To Get A Title Out A Html File
I'm trying to create a search engine, but now I need to get the title from the file as output.

How Can I Hide A Title Bar In A Nw Window.
I am oening a new window from javascript function

window.open('imgShow.php','ImageName', 'width=100,height=100,titlebar=no,
screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y);

I added titlebar=no Still its showing titlebar.

I want to hide title bar as well as minimise and close option.
I want no border to HTML page. Can anyone suggest me what are the possible options to do this. I have a grid of picture and on mouseover i want to show big image over it.

Get_meta_tags Prblm If <title> Contains A '
I have a source html file. I use the get_meta_tags function to parse the content of meta,
such as description. It works fine, but in a particolar situation it does not works.
If I have:inside head section:
<title>Il mio nome e' pippo</title> <meta name="description" content="ciao ciao"> then calling PHP Code:

Displaying Title As A Link
I'm developing a simple CMS which displays the names of pictures on a page.

(ex: Picture 1 - This is picture 1
      Picture 2 - This is picture 2.
)

The pictures are uploaded to the database using a form. If someone clicks the above titles, the user should be directed to a page containing the picture (ex: www.example.com/picture1.

I am wondering how I go about this, and how to make susck titles appear as links. Sorry I sound very naiive, but I've only recently started with PHP(been 3 days)

Accessing A Website's Title
Is there any way we can access the title of a web page through php?
This is how I want it work:

1. User inputs webpage address in a form.

2. My website should display the title of the inputted website(as in, 'www.google.com' has a title of 'Google - Home').

Any ideas?

Reading HTML Title In PHP
I am challenged with the task of writing a PHP script that will prompt the user for a website (ex: yahoo.com). When submitted, the PHP script will somehow open the web page as a file, somehow search the source, find the <title> tag, and return the title of the web page..

If someone knows an easier approach to this, I would appreciate it. Opening an entire website as a variable seems like a bit of overkill..

Heres where I'm at so far, I'm kind of looking for a push in the right direction. I've been googling for awhile now trying to find out how to tackle this, but searching for things like "php, website, title, web page, HTML" hasn't proved too successful..

<?php

// Assigns $site from the form text box named "site"
//
$site = $_POST['site'];

$file = fopen($site, "r");

// This needs to open the text-source of the inputted webpage.  
// From here I will search for the <title> tag in the HTML...
//
echo "$file";
echo "<br><hr>";

?>

Dynamic Title Tags Within A Template
looking for suggestion on the best way to create unique title tags within a templated system.  In other words, I have a standard header, footer, left nav, for each of the pages I create.  Works extremely well.  The only problem is that the title tag in the header is the same for every page. Suggestions or thoughts as to how make each page have a unique title tag would be great.

Change Window Title Of WebServer
I have a webserver that I host. The problem is, when the URL is entered, it shows the IP address of the server in the address bar, and not the URL (i.e. www.mysite.com). The server used to be hosted by a company, but now we have them forward the URL requests to our server.

Dynamically Managing Certain Document Aspects (e.g. Title)
I have this Javascript code snippet which I add to the "onload" event
of the "<body>" tag:

document.title = document.getElementById('column_title').innerHTML;

The element id "columnt_title" is the id of a heading ("<h1>") on the
page that happens to be the title of the main article on that page.

I couldn't find this in the help or main reference documents on
php.org. I'm sure it's pretty simple. Is it....

Can Include File Read Its Parents <title> And URL ?
I have a php file in which I am including(not really with include statement but <img src=""> ) an other file which does some processing work before outputting a GD generated image. PHP Code:

Weird Query Results / <title> Issues
I'm editing some stuff I did last summer, trying to bugfix and improve
stuff. One improvement (or an oversight of the original design) is
adding dynamic <title> tags to my pages. Here's how I originally
structured my php pages:

include header.php (contents are basically my HTML/CSS up to the
<!--begin content--> point)
<php code>
include footer.php (contents are from <!--end content--> onwards).

Obviously this meant I had the same <title> as defined in header.php
for every page, not cool. I went through and revised the structure to
this:

include doctype.php (HTML from the opening document declaration down to
just before <title>)
Then began my query(s), and once the results were grabbed:
echo "<title>$bandName - recordName review</title";
include header.php (this file now contains everything below <title>
down to <!--begin content-->)
<php code to output content>
include footer.php (as above)

This worked great for almost all of my pages but one. Here's the link:

This might look normal to you, but try clicking some of the other
reviews in the left panel. The cover image and headings stay the same,
and the author information at the bottom again stays the same, which is
of course incorrect. I'm not sure where I'm going wrong with my code,
so I'll post up what I'm doing:

That file has doctype.php, header.php and footer.php physically
included so you can see their contents too (ordinarily they're included
with php includes).

Split Title From Date In Field Using Preg_replace
I am building a CSV file but one of the fields for titles contains the title and a date at the end in the format of dd/mm/yy, such as

"summer manual 03/01/07".

I want to split this into two csv fields by doing this,

"summer manual,03/01/07".

What regex do you need to search for the dd/mm/yy part of the string? I am not very good at these myself.

PHP To Insert Header TITLE And META TAGS
I'm trying to customise PHP pages by setting variables for the page Title and the Meta Tags for Description and Keywords.

I did this by creating three variables - $title, $description and $keywords at the head of individual pages, then inserting the following code into my header.php file which delivers the header and left column (nav) to each page of the site:

<title><?php echo $title ?></title>

and similar code for the meta tags for description and keywords.

No problems with Firefox, but in IE6 I get the $title printed at the top of the page instead of in the blue bar at the top of the browser.  Yet no meta tags are printed on the page - but they appear normally along with the title in the page source.

Is this a quirk in IE (which I loathe, but I know so many people use) or something I've done incorrectly in my code?

In ASP you can write <% =strTitle %>  but is there something similar in PHP that I haven't discovered yet?

Thumbnail Images With Rollover Post Title
I'm trying to have alter a featured posts plugin on Wordpress. I'd like to have the thumbnail appear with the title appear when the user rolls over the image. Code:

How To Pull Existing Title Tag Into The Body Of The Document As Textonly
I need to be able to pull the current <Title> tag from the header into
the body of the html page. We started coding this with php, and we
were able to get it working. However the entire page is being parsed
and really bogging down the system and the pages load very slowly.
(the system is Dual P4 2.4, 1GB ram, Redhat 9.0)
To fix this we decided to just use javascript, which worked great.
Text loaded immediately. However, search engines will not process the
javascript, thus this text will not be available in the document to be
scanned.
Does anyone have a way to pull a title tag from a document and display
its content as text only within a document, Without loading down the
system? When we tried it, it took the pages at least 5 times longer to
load than without the code.

Changing Php.ini
is there a way to change values in php.ini (like adding support for certain things) if you are not hosting your site yourself, like using a pay host?


Copyright © 2005-08 www.BigResource.com, All rights reserved