Jul 25, 2008

Another Php Question - This is really simple one...

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Another Php Question - This is really simple one...

matak
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

CODE
<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"

CODE

<?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 smile.gif




 

 

 


Reply

Saint_Michael
well you could set up a php nav menu like so:

http://www.stilisticdev.net/tutorials.php?...02&cmd=full

Thus you can create your links with that.

Reply

jlhaslip
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.

Reply

matak
QUOTE(jlhaslip @ Oct 24 2006, 06:10 PM) *

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 smile.gif
It displays this result
EOF; include "$content.inc"; echo<<Home Links EOF; ?>
...
Well, it is a start in good direction, anyway...

 

 

 


Reply

contor
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:
CODE
<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.
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:
CODE

{ 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: http://"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 tongue.gif
i hope it was usefull for you



Reply

jlhaslip
Yes, if you wish to have an "external" page showing inside your own page, use an iframe.

Reply

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

CODE

<?php
echo "<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 smile.gif

Reply

contor
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:
CODE

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.

Reply

matak
hts and contor..
thanks for all of that code.. now i have answers for 10h of practice. smile.gif

I'll be back with the results and the chosen code. And chosen code.

to jlhaslip
when 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 3

Notice: Use of undefined constant page - assumed 'page' in F:\WebServer\Apache2\htdocs\1o\content_handler.php on line 4
index
Notice: Use of undefined constant page - assumed 'page' in F:\WebServer\Apache2\htdocs\1o\content_handler.php on line 6

what could it be?

Reply

jlhaslip
CODE
$submit = $_GET[page];
echo  $_GET[page];

if( !isset($_GET[page])   )

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?

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics
Looking for php, simple

Searching Video's for php, simple
advertisement



Another Php Question - This is really simple one...



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE