spfoonnewb Posted August 4, 2006 Share Posted August 4, 2006 Is this possible?I defined title on the page being includded using:[code]<?php$title = 'Title';$title2 = 'Description';?>[/code]Then I tried to call it on the page with the array/dynamic include using:[code]<?php$title = $_GET['title']; $title2 = $_GET['description']; echo '<title>$title</title>';echo '<description>$title2</description>';?>[/code]Why doesnt that work? Quote Link to comment https://forums.phpfreaks.com/topic/16580-posting-title-using-_get/ Share on other sites More sharing options...
hitman6003 Posted August 4, 2006 Share Posted August 4, 2006 What you're asking for doesn't make sense.What about it doesn't make sense? Are you passing $title and $title2 in the url? If not, why are you using $_GET? Quote Link to comment https://forums.phpfreaks.com/topic/16580-posting-title-using-_get/#findComment-69385 Share on other sites More sharing options...
spfoonnewb Posted August 4, 2006 Author Share Posted August 4, 2006 Im using $_GET cause thats the idea, and post doesnt work.Basically I want the value defined in the page being includedAnd the page that is doing the inclusion to post it Quote Link to comment https://forums.phpfreaks.com/topic/16580-posting-title-using-_get/#findComment-69388 Share on other sites More sharing options...
hitman6003 Posted August 4, 2006 Share Posted August 4, 2006 Use double quotes:[code]echo "<title>$title</title>";echo "<description>$title2</description>";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16580-posting-title-using-_get/#findComment-69390 Share on other sites More sharing options...
ignace Posted August 4, 2006 Share Posted August 4, 2006 Hitman is right! It ain't working because single quotes will not parse variables, don't ask why!They also do not parse newlines (\n) therefore you need to use double quotes, they will do the trick... There goes my fine neat coding... Quote Link to comment https://forums.phpfreaks.com/topic/16580-posting-title-using-_get/#findComment-69391 Share on other sites More sharing options...
spfoonnewb Posted August 4, 2006 Author Share Posted August 4, 2006 Ok, well whether I define it using[code]<?php$title = 'Title';$title2 = 'Description';?>[/code]Or[code]<?php$title = "Title";$title2 = "Description";?>[/code]And Use [code]<?php$title = $_GET['title']; $title2 = $_GET['description']; echo "<title>$title</title>";echo "<description>$title2</description>";?>[/code]Or [code]<?php$title = $_POST['title']; $title2 = $_POST['description']; echo "<title>$title</title>";echo "<description>$title2</description>";?>[/code]The output does not contain "Title" Although it was defined and it just looks like:[code]<title></title><description></description>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16580-posting-title-using-_get/#findComment-69395 Share on other sites More sharing options...
spfoonnewb Posted August 4, 2006 Author Share Posted August 4, 2006 Now I think it doesnt work because its being called before its defined.It's defined halfway through the inclusion page not the top, and its called at the top of the inclusion page.But it doesnt work well unless its in the head, so I dunno.Is there a way to say : Execute this last! :? Quote Link to comment https://forums.phpfreaks.com/topic/16580-posting-title-using-_get/#findComment-69409 Share on other sites More sharing options...
kenrbnsn Posted August 4, 2006 Share Posted August 4, 2006 Please put these lines at the top of you script:[code]<?phpif (isset($_GET)) echo '<pre>$_GET: ' . print_r($_GET,true) . '</pre>';if (isset($_POST)) echo '<pre>$_POST: ' . print_r($_POST,true) . '</pre>';?>[/code]and post whatever is printed on your screen.If you are not starting your script from a forn or using someother way to pass data via the POST array, you will get nothing when using $_POST. If there are not values on the URL, there will be nothing in $_GET.Also describe exactly what you are trying to do. Post all the scripts if necessary.Ken Quote Link to comment https://forums.phpfreaks.com/topic/16580-posting-title-using-_get/#findComment-69412 Share on other sites More sharing options...
spfoonnewb Posted August 4, 2006 Author Share Posted August 4, 2006 heres what that gave me:[code]$_GET: Array( [p] => test)$_POST: Array()[/code]Leme type some more Quote Link to comment https://forums.phpfreaks.com/topic/16580-posting-title-using-_get/#findComment-69416 Share on other sites More sharing options...
kenrbnsn Posted August 4, 2006 Share Posted August 4, 2006 So there is no title= or description= on the URL. That's why you're not seeing anything.Ken Quote Link to comment https://forums.phpfreaks.com/topic/16580-posting-title-using-_get/#findComment-69419 Share on other sites More sharing options...
spfoonnewb Posted August 4, 2006 Author Share Posted August 4, 2006 I am basically using:[code]<?php $pages = array( 'test' => 'includes/test.php', ); if (isset($_GET['p']) && isset($pages[$_GET['p']])) { include($pages[$_GET['p']]); } else { header("Location:index.php"); }?>[/code]So I am trying to title the page based on what I want it to be.So what I tried to do was define the title in the page being included i.e: test.phpThen on the page doing the inclusion I added a $_POST or $_GET to try and get that variable that was defined.The script looks kinda like this:[code]<html><head><title>$_GET/POST[title];</title></head><body>THE ARRAY</body></html>[/code]test.php Is whatever I want it to be and I am trying to define the title.[code]<?php$title = 'Title';$title2 = 'Description';?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16580-posting-title-using-_get/#findComment-69430 Share on other sites More sharing options...
FFEMTcJ Posted August 4, 2006 Share Posted August 4, 2006 I use a header and a footer page that are generic and then a content page that differes for each page.. In the header page I have this:[code]<?phpecho<<<FACE_BEGIN<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>$title</title>[/code] and it continues on with the rest of the header... In the content page it is like this:[code]<?php/* Page Title */$title="Paige's Movies";[/code] and that continues... If you want to see the pages go to www.paigejohnston.com... The front page doesn't use this format, but every other page on the site does. Quote Link to comment https://forums.phpfreaks.com/topic/16580-posting-title-using-_get/#findComment-69499 Share on other sites More sharing options...
SithLord2K Posted October 24, 2006 Share Posted October 24, 2006 Ok I know exactly what you are trying to do. I just figured it out for my own website. Try this. On the page being included, before everything else a he floowing code.[code]<?php$pages = array( 'test' => 'includes/test.php', ); if (isset($_GET['p']) && isset($pages[$_GET['p']])) { $title = "[i]title[/i]"; $description = "[i]description[/i]"; //Can also be $pages or whatever your varible is }else{ $title = "[i]alternate_title[/i]"; //You can leave blank $descrition = "[i]alternate_description[/i]"; //You can leave blank }?>[/code]Then where you call these put this:[code]<?php echo $title; ?><?php echo $description; ?>[/code]or however you want to call themBelow is an example of the script my site uses:[code]<?PHP$valid_pages = array('news', 'about', 'contact', 'pricing', 'portfolio', 'main', 'legal');$page = $_GET['page'];if (in_array($page, $valid_pages)){ $subTitle = $title." - ".$page;}else{ $subTitle = $title; }?>[/code]then when I call the script I used:[code]<title><?php echo $subTitle; ?></title>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16580-posting-title-using-_get/#findComment-113481 Share on other sites More sharing options...
fert Posted October 24, 2006 Share Posted October 24, 2006 use[code]echo "<title>{$_GET[title]}</title>";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16580-posting-title-using-_get/#findComment-113487 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.