PHP Question please
Moderator: General Moderators
PHP Question please
I am making awebsite, but i want it to be friendly with every one so no iframes
BUT!! i don;'t want to make a thousand pages with the same stuff and having to update all of them if i just need to do one little link...so whats the PHP of doing it so you only change the main body of text
thanks!!
BUT!! i don;'t want to make a thousand pages with the same stuff and having to update all of them if i just need to do one little link...so whats the PHP of doing it so you only change the main body of text
thanks!!
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
I,so whats the PHP of doing it so you only change the main body of text
1) Did not understand that question, and
2) Did not understand a word you said in your above post, so
You should,
1) Re-ask your question, in regular english, and
2) Slow down when your making a post, and re-read it before you actually post it. Make sure that people can understand exactly what your talking about.
You need case/switch and GET variables:
And on whatever page you choose to have the action be...
Code: Select all
<form action="" method="get">
Go to Page: <input type="text" name="page">
</form>Code: Select all
if(isset($_GET['page']){
$page = $_GET['page'];
switch($page){
case 'home':
echo 'This is the home page.';
break;
case 'other':
echo 'this is another page..';
break;
}
}
?>i suggest using includes and just include the data that is changing
http://us3.php.net/manual/en/function.include.php
also learn about $_GET[]
then you can do something like this
example of url. http://www.mypage.com/?page=news would include news.php
http://www.mypage.com/?page=news would inlclude staff.php
http://us3.php.net/manual/en/function.include.php
also learn about $_GET[]
then you can do something like this
example of url. http://www.mypage.com/?page=news would include news.php
http://www.mypage.com/?page=news would inlclude staff.php
Code: Select all
switch($_GET['page'])
{
default:
case 'news':
include('news.php');
break;
case 'staff':
include('staff.php');
break;
}Hehe... yea. I think I was a split second before youPrObLeM wrote:oops Steveo31 we posted at the same time
We seemed to understand, be nice.Illusionist wrote:I,so whats the PHP of doing it so you only change the main body of text
1) Did not understand that question, and
2) Did not understand a word you said in your above post, so
You should,
1) Re-ask your question, in regular english, and
2) Slow down when your making a post, and re-read it before you actually post it. Make sure that people can understand exactly what your talking about.
Last edited by Steveo31 on Mon Mar 29, 2004 5:52 pm, edited 1 time in total.
oh i forgot to mention the linkes would look like this
Code: Select all
<a href="?page=news">News!</a> <br>
<a href="?page=staff">Staff!</a>-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
simple php script:
PHP is basically the oposite of SSI, in a way. This time you make the layout first, then you add the content. This is much faster at loading than SSI aswell. If you want to learn PHP, then I suggest that you learn SSI first. If you know SSI, then this will be alot easier to understand. If you wish to continute, simply follow the steps below.
Step 1
First off, make sure your host supports PHP! Angelfire, Geocities and most other free hosts wont but there are some, such as Host Ultra (who suck anyway).
Step 2
Make a layout with no content in it (an empty content area).
Step 3
Look for the place in your html you want the content to appear at and insert the following code:
<?php include ("$id"); ?>
Step 4
Save that page as main.php
Step 5
Now you have to create a page with just content, and no layout. You can call it whatever you want. In this case, we called it linkus.txt
Step 6
Upload both of these pages to your host and type in this url, http://www.yourhost.com/main.php?page=linkus.txt
NOTE: Dont forget to replace http://www.yourhost.com/ with your hosts URL!
Step 7
Go to that page and check to see if it is working correctly. It should work first time if you followed the instructions correctly.
I am dislexic
:p
<quote>
if(isset($_GET['page']){
$page = $_GET['page'];
switch($page){
case 'home':
echo 'This is the home page.';
break;
case 'other':
echo 'this is another page..';
break;
}
} </quote>
Now the part that says
<quote> case 'other':
echo 'this is another page..';
break; </quote> Is that actually nessary, like will i need to add that part there for every page i have?
:p
<quote>
if(isset($_GET['page']){
$page = $_GET['page'];
switch($page){
case 'home':
echo 'This is the home page.';
break;
case 'other':
echo 'this is another page..';
break;
}
} </quote>
Now the part that says
<quote> case 'other':
echo 'this is another page..';
break; </quote> Is that actually nessary, like will i need to add that part there for every page i have?
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
theres only a small error in the steps
change
BUT!!!WARNING that is very VERY INSECURE!!!! so watch out...!!!! 
change
TOStep 3
Look for the place in your html you want the content to appear at and insert the following code:
<?php include ("$id"); ?>
Step 3
Look for the place in your html you want the content to appear at and insert the following code:
<?php
if(isset($_GET['page'])
{
include ($_GET['page']);
}
?>
Last edited by PrObLeM on Mon Mar 29, 2004 6:03 pm, edited 1 time in total.
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
RavenMist, say you have 3 links:
Then your switch would look something like this:
Code: Select all
<a href="?page=home">Home</a>
<a href="?page=downloads">Downloads</a>
<a href="?page=contact">Contact</a>Code: Select all
if(isset($_GET['page']){
$page = $_GET['page'];
switch($page){
case 'home':
echo 'This is the home page.';
//or if you have a main homepage you can do like:
//include("home.html");
break;
case 'downloads':
echo 'this is downloads page..';
//include("downloads.html");
break;
case 'contact':
echo 'this is contact page.';
//include("contact.html");
break;
}
}