Jump to content

Hii i am new to php....


truenitin

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

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.
Link to comment
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.