Jump to content

Archived

This topic is now archived and is closed to further replies.

truenitin

Hii i am new to php....

how to load page through index.php something like index.php>the page  

  1. 1. how to load page through index.php something like index.php>the page

    • a
      0
    • d
      0


Recommended Posts

i am new to new php i am trying to learn to load pages through index.php. Help me out...

Share this post


Link to post
Share on other sites
Could you please provide more infomation as your question is a little vague.

Share this post


Link to post
Share on other sites
you add a link to goto another page ok.

example

first 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 page

test1.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 done

now the header to include in index.php


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

Share this post


Link to post
Share on other sites
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.php

the header has the main menu.

the main menu has member login which will call the mainlogin.php

now when i click on member login it should call mainlogin.php

i can add the link to it as /mainlogin.php

but i

i want the mainlogin to be read dynamically by doing something like this

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

Share this post


Link to post
Share on other sites

×

Important Information

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.