truenitin Posted July 4, 2006 Share Posted July 4, 2006 i am new to new php i am trying to learn to load pages through index.php. Help me out... Quote Link to comment https://forums.phpfreaks.com/topic/13628-hii-i-am-new-to-php/ Share on other sites More sharing options...
wildteen88 Posted July 4, 2006 Share Posted July 4, 2006 Could you please provide more infomation as your question is a little vague. Quote Link to comment https://forums.phpfreaks.com/topic/13628-hii-i-am-new-to-php/#findComment-52819 Share on other sites More sharing options...
redarrow Posted July 4, 2006 Share Posted July 4, 2006 you add a link to goto another page ok.examplefirst make a page called test.php<?echo " hello i love php ";?>in index.php add a link like<?echo "<a href='test.php'>go to test page please</a";?>or to make more complex and more relable use a template to all pages.make pagetest1.php<?echo " this is my test page";?>test2.php<?echo " this is another test page";?>test3.php<?echo " this is the 3rd test page";?>thats the pages donenow the header to include in index.phpheader.php<?echo "<a href='test1.php'>go to test page please</a";echo "<a href='test2.php'>go to test page please</a";echo "<a href='test3.php'>go to test page please</a";?>now the headers done i need index.php to get the header to link to all pages.header.php<?// include is a php statement to add an extenal page to a page.include("header.php");?>thats it now you got 3 pages from header.php linked to index.php now if you add the include("header.php"); to all the other pages you got a link template ok.please note// all links need a > at the end can not post on forum ok.good luck mate.If you want to no how to pass data from one page to another please look up sessions ok. Quote Link to comment https://forums.phpfreaks.com/topic/13628-hii-i-am-new-to-php/#findComment-52820 Share on other sites More sharing options...
truenitin Posted July 4, 2006 Author Share Posted July 4, 2006 it is something like this i want the index page as the main page i want the header and footer to be included in all the pages.now i have a login file mainlogin.phpthe header has the main menu.the main menu has member login which will call the mainlogin.phpnow when i click on member login it should call mainlogin.php i can add the link to it as /mainlogin.phpbut ii want the mainlogin to be read dynamically by doing something like thisindex.php code.<?php$p = $_GET['page']; if (strpos($p,"..")) { die("Bad page request");}if (!$p) $p = "index";$content_file=$_SERVER["DOCUMENT_ROOT"]."/".$p.".php";if (!file_exists($content_file)) { header("Location: {$_SERVER["PHP_SELF"]}"); exit();}$title = ($p) ? "$p - My Site!" : "Main page - My Site!";include("header.php");include($content_file);include("footer.php");?>how will this code read my mainlogin.php file when i click on member login.i want the link dynamic in my menu. Quote Link to comment https://forums.phpfreaks.com/topic/13628-hii-i-am-new-to-php/#findComment-52867 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.