Jump to content
xisto Community
Sign in to follow this  
matak

Another Php Question This is really simple one...

Recommended Posts

Well i'm noob PHP programmer, but i'm learning slowly. I found a good script from jlhaslip called "PHP/Flat-file Web Site Template".
Well, that is what i need for my practice but i can't understand it quite right.
(please don't start talking about better ways beacouse i know of them)
My idea is
index page with standard menu footer and header (basicly a template)
So this means i should have these files
index.php
mycss.css
content_handler.php
index.txt
away.txt

in index.php i would put a div tag

<div id="content"></div>

ok now that i have "content" i should have some file to manage it (i used jlhaslips way)
a piece of code that goes inside "div tag"

<?php	 include("content_handler.php");?>

Now in index.php i have allready defined "menu" and let's say it looks like this

Home --->link to index.txt
Away --->link to away.txt

What code should i put in content_handler.php so that when i click on Away link it just changes the content of index.php "content" div tag?

I know there is lot's of guides in php but i just don't know the proper way to google this one, and i could use some credits for hosting :lol:

Share this post


Link to post
Share on other sites

Matak,If you are using the zip file from my siggy, unzip it and look in your Browser at the index.php file. Actually, the files for the menu creation script. A couple of pages into the Template. The name of the file should be defined in the "acceptable" list, too. The "included" files are defined as ".txt" files. If you want a php file for content, you must change that, too.The menu is built using a flat-file. It should be explained in the Tutorial which the zip file, I think, contains. Post back if it is not properly explained.

Share this post


Link to post
Share on other sites

Matak, If you are using the zip file from my siggy, unzip it and look in your Browser at the index.php file. Actually, the files for the menu creation script. A couple of pages into the Template. The name of the file should be defined in the "acceptable" list, too. The "included" files are defined as ".txt" files. If you want a php file for content, you must change that, too. The menu is built using a flat-file. It should be explained in the Tutorial which the zip file, I think, contains. Post back if it is not properly explained.


No no.. your tutorial is bit out of my league. (i could change it but i don't like using lot's of CSS, it get's things a bit more comlicated) Saint_Michael this code u linked doesn't work for me when i copy/paste it.. you can check results on My Webpage (if it doesn't work well it's my local server so there could be many reasons for that :lol: It displays this result EOF; include "$content.inc"; echo<<Home Links EOF; ?> ... Well, it is a start in good direction, anyway...


Share this post


Link to post
Share on other sites

i have the solution for you because i do the same in my website. Its not so difficult to do this but you should have the age perfectly organized. The method to add a page into another is the tag "<iframe>" this is the completly code that i have in my page of the iframe:


<iframe allowtransparency="true" style="FILTER: chroma (color=fafefd)"name="Main" src="/contact.php" SCROLLING="no" width="100%" height="600" align="top" frameborder="0" class="wrapper"> Esta opci�n no trabajar� correctamente. Su navegador no soporta IFRAMES.</iframe>

The code i use in my page is a funtion call if (if you started learning php you should know it), so suppouse you have 3 pages to add into a page "home.php"(this is your home page) "page2.php" and "page3.php". So you open your header and footer page and were you want to see the page you add something like this code.


if($seccion=='page2') {echo '<iframe allowtransparency="true" style="FILTER: chroma (color=fafefd)"name="Main" src="Page rute 2 EJ: "/page2.php" " SCROLLING="no" width="100%" height="600" align="top" frameborder="0" class="wrapper"> your brouser doent allow iframes.</iframe>'; } else { if($seccion=='page3') {echo '<iframe allowtransparency="true" style="FILTER: chroma (color=fafefd)"name="Main" src="RUTA PAGINA 3 EJ: "/page3.php" " SCROLLING="no" width="100%" height="600" align="top" frameborder="0" class="wrapper"> your brouser doent allow iframes..</iframe>'; } else { echo '<iframe allowtransparency="true" style="FILTER: chroma (color=fafefd)"name="Main" src="Page rute home EJ: "/home.php" " SCROLLING="no" width="100%" height="600" align="top" frameborder="0" class="wrapper"> your brouser doent allow iframes..</iframe>'; }; };

This code vercion i have recently made is not the one i have in my website because althout it is more easy to understand, it is disorganise. You can have ilimitate number of pages the only thing you have to do is to copy one line and add it before:


{ echo '<iframe allowtransparency="true" style="FILTER: chroma (color=fafefd)"name="Main" src="Page rute home EJ: "/home.php" " SCROLLING="no" width="100%" height="600" align="top" frameborder="0" class="wrapper"> your brouser doent allow iframes..</iframe>'; };

,add an "};" at the end, change the variable "seccion" value, and the page rute. I said to change the variable value because it is fundamental for the page EJ: the variable for the page2.php is $seccion=='page2'. the link to show that page is: "yourpage".com/"theheaderandfooterfile".php?seccion=page2 so you can acces all the pages from one only page. If you find anything in spanish is my fault because my native lenguage is spanish :lol: i hope it was usefull for you


Share this post


Link to post
Share on other sites

it can be done much much simpler, no iframes or such:

<?phpecho "<div class=\"content\">";$page=$_GET['page'];$page.="php";include($page);echo "</div>";?>

and your url`s will be like: index.php?page=about

this will include in index.php, the about.php page (if this is found in the same directory as index.php).
well, this piece of code has security problems, as the $_GET[] value is not sanitized...but that`s another story...just understand this and we`ll continue afterwards :lol:
Edited by hts (see edit history)

Share this post


Link to post
Share on other sites

Yea i think is the best idea to have it on a diferent page, is more organised but if you matak want
to have it on one sheet of paper you can use if like in my other post but adding directly the
code of the page.
EJ:

if($seccion=='page2')   {echo 'page code';}   else	{if($seccion=='page3'){echo 'page 3 code';}else{echo 'home page code'};};
this is a less organized way to have all pages in one but is the least organized
you can think anothers ways, and there are more advanced ways to do it but
this is the best for you to understand and that with logic everything is pocible.
Edited by contor (see edit history)

Share this post


Link to post
Share on other sites

hts and contor..thanks for all of that code.. now i have answers for 10h of practice. :lol:I'll be back with the results and the chosen code. And chosen code.to jlhaslipwhen i download template from your sig and "install" it i get this error..Notice: Use of undefined constant page - assumed 'page' in F:\WebServer\Apache2\htdocs\1o\content_handler.php on line 3Notice: Use of undefined constant page - assumed 'page' in F:\WebServer\Apache2\htdocs\1o\content_handler.php on line 4indexNotice: Use of undefined constant page - assumed 'page' in F:\WebServer\Apache2\htdocs\1o\content_handler.php on line 6what could it be?

Share this post


Link to post
Share on other sites

$submit = $_GET

;echo  $_GET

;if( !isset($_GET

)   )
I would say it doesn't like these get statements, but I don't know why. Unless you aren't running it through a Browser and failing to "get" a value?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.