PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old August 10th, 2002, 07:40 AM
legion legion is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Auckland, New Zealand
Posts: 6 legion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
A newbie newbie question

Hello

I am trying to build a template driven website (powered by php) but I suck so much so I gave up and came here :p how would I go around doing that?

Like, the link will have something like index.php?page=about

and depending on the "page=" it would include a different file

how would I go around doing that? Thanks

oh and btw my php verson is php-4.2.2

Reply With Quote
  #2  
Old August 10th, 2002, 07:56 AM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to EvilivE
RE: A newbie newbie question

One way is like this:
php Code:
Original - php Code
  1. <?php
  2. if(empty($_POST['page'])){
  3.   // include default file
  4. } else {
  5.   include("/path/to/file/".$_POST['page'].".ext");
  6. }


Not sure if your new to just PHP or programming all together. If the above makes no sense, reply and you will get more help.

HTH

Reply With Quote
  #3  
Old August 10th, 2002, 08:08 AM
legion legion is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Auckland, New Zealand
Posts: 6 legion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: A newbie newbie question

yes, that would be it, I suck

If the file and the script is at the same directory what would be the path?

and does that scrpt work with my php verson? just asking because whole lot of scripts stoped working as soon as I upgraded php-and now people are telling me to use qurrey string or something (not that I want to)

thanksssssseeeee

Reply With Quote
  #4  
Old August 10th, 2002, 08:27 AM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to EvilivE
RE: A newbie newbie question

That script will work with your version of PHP. If the file and the script are in the same directory your include statement would be:
php Code:
Original - php Code
  1.  
  2. <?
  3. include($_POST['page'].".ext");
  4. ?>

More clarification:
1. Replace .ext with the correct extension of the filename.
2. The /path/to/file/ format is assuming *nix box. If you are on a Win32 box then it would be C:\path\to\file\
3. The script assumes that it is getting the data from a form submission with method set to POST. If you are useing GET then change all occurances of $_POST to $_GET.

HTH

Reply With Quote
  #5  
Old August 10th, 2002, 08:31 AM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to EvilivE
RE: A newbie newbie question

Quote:
Like, the link will have something like index.php?page=about


Use $_GET['page']

Reply With Quote
  #6  
Old August 10th, 2002, 08:51 AM
legion legion is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Auckland, New Zealand
Posts: 6 legion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: A newbie newbie question

Its not working. I must suck sooooo much

this is my index.php

php Code:
Original - php Code
  1. <body>
  2.  
  3. <a href=index.php?page=faq>asdfasd</a><br><br><br><br>
  4.  
  5. <?php
  6. if(empty($_POST['page'])){
  7.   // include default file
  8. } else {
  9.  include($_POST['page'].".txt");
  10. }
  11. ?>


link to that is

http://ubin.nzpages.net/index.php
_______________________________________
This is my faq.txt

php Code:
Original - php Code
  1. xdfg


link to that is

http://ubin.nzpages.net/faq.txt

Try going to the index.php and click on the link. nothing shows up *cries*

Reply With Quote
  #7  
Old August 10th, 2002, 09:03 AM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to EvilivE
RE: A newbie newbie question

When you said "... include a different file", hmmm include is a "keyword" in PHP. So what is it that you want to do?

Do you want to show the contents of faq.txt?

Reply With Quote
  #8  
Old August 10th, 2002, 09:10 AM
legion legion is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Auckland, New Zealand
Posts: 6 legion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: A newbie newbie question

I want to show the contents of faq.txt [depending on what the "page=x" is]

sorry for being an idiot (I cant help it)

Reply With Quote
  #9  
Old August 10th, 2002, 09:36 AM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to EvilivE
RE: A newbie newbie question

How were you suppose to know that "include" was a keyword, its my misinterpretation.

Also you see the text in yellow above "// include default file" that is a comment.

OK, try this for your index.php file:
php Code:
Original - php Code
  1. <html>
  2. <body>
  3. <a href=index.php?page=faq>asdfasd</a>
  4.  
  5. <?php
  6. if(!empty($_GET['page'])){
  7.   show_source($_GET['page'].".txt");
  8. }
  9. ?>
  10. </body>
  11. </html>


That should do it for now, I guarantee that there will be more.

Reply With Quote
  #10  
Old August 10th, 2002, 09:43 AM
legion legion is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Auckland, New Zealand
Posts: 6 legion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: A newbie newbie question

omgomgomgomgomgomgomg it works! omgomgomgomgomg thank you sooooooooooooooooooooo much!! thank you!!!!!! D

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > A newbie newbie question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek