View Full Version : php: How do I connect $title variable to another webpage?

June 22nd, 2007, 12:11 PM
My header.inc file.

"-//W3C//DTD HTML 4.01//EN"

<html lang="en">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="description" content="Den bästa bokhandeln som jag har gjort hittills!">
<meta name="keywords" content="film, filmer, billigt, ebutik">

print "<title>" . $_REQUEST["$title"] . "</title>";

<style type="text/css" media="screen">

My index.php file.

$title = "PHP + CSS exempel";
include "header.inc";

I don't know exactly how to store the $title variable in index.php to get my heather.inc to grab the values in variable $title and print it out in my browser?
I'm reading in my nightcourse notes but so far I only find methods for making GET links and POST forms none of which seems to fit into this problem. I'll continue searching for the answer in my notes and papers but would appreciate some guidance so I know what I should look for?

June 22nd, 2007, 01:07 PM
I'm guessing that I should use something like this with the date example?

<form method="POST" action="reciever.php">
<input type="hidden" name"datum"
value="<?php pring date("Y-m-d" ?>">

and then use $_REQUEST[datum] on the reciever.php webpage.

June 22nd, 2007, 01:51 PM
You don't need to do $_REQUEST["$title"]; just do $title;

June 22nd, 2007, 04:02 PM
Yep you just have to add to a simple variable the title name and then recall it at the header page!

string $title = "you title name";

<title><?php echo($title); ?></title>
----> some other code <----


June 22nd, 2007, 04:06 PM
There's no need to do echo( $title ); - just echo $title will do

Also, with PHP you dont define the type of a var, as in you don't do "string $title" but just do $title = "your title name";

June 22nd, 2007, 04:08 PM
And if you have short tags enabled, instead of

<?php echo($title); ?>

You can do

<?=$title; ?>

June 22nd, 2007, 04:09 PM
well AlexC_ what you wrote are just details and i guess we are not running after those details ... important the core to be right!

June 22nd, 2007, 04:20 PM
indeed, however by doing "string $var;" would lead to a syntax error.

HymnToLife, you shouldn't really be using short-tags, afaik they are not enabled by default and so can cause issues if you need to move the script else where, it's always best habbit to do <?php ... instead of <?

June 22nd, 2007, 10:20 PM
hehe it worked Y...MCA \\:D/ *dances* tnx ppl.