Jul 26, 2008

Php Linking - One of the major advantages of PHP is the ability to create something

Free Web Hosting, No Ads > CONTRIBUTE > Tutorials

free web hosting

Php Linking - One of the major advantages of PHP is the ability to create something

KansukeKojima
PHP Links
Requirements
1. You should understand the majority of PHP (ex: variables, echo, etc. www.w3schools.com is a good reference).
2. Experienced with HTML.
3. You need a PHP compatible server if you wish to see your results.

Description
One of the major advantages of PHP is the ability to create something similar to an Iframe, only without the scroll-bar. The main advantage of this is that you only need one layout page, while the others can be simple 'white space & content' pages. Another advantage of this is your web site doesn't look like a fifth grader coded it.

Try It Out
The Code

CODE
<?php $default = "blah.html"; if($id == ""){$id = $default;}elseif(isset($id)){$id = $id;} ?>
<?php include ("$id"); ?>


Alright, so now your asking, "What the fudge!?" I'll explain it to you.

The $default variable is the default page that will appear when a visitor comes to your site. The Replace blah.html with the location of your default or main page. Now when somebody visits your site they will see that page.

See that include tag? This tells your server to include whatever $id is equal to. The tag above it makes $id equal to whatever you file you chose for $default. So how do we create a link? We simply change what $id is equal to using some everyday HTML - with a twist.

The Code

CODE
<a href="?id=blah2.html">Link Text</a>


See the twist? Using ?id=blah2.html we are able to change what $id is equal to. Replace blah2.html with whatever page you want to create a link.

Get it? If not then try reading it over a few times.

 

 

 


Reply

iGuest
Question on your code

Php Linking



I'm a newbie to php, so forgive me for the ignorant questions I might have for you!

I'm trying to create your PHP link code:
CODE
<?php $default = "blah.Html"; if($id == ""){$id = $default;}elseif(isset($id)){$id = $id;} ?>
<?php include ("$id"); ?>

With mine:
<?php $default = "venue.Php"; if($club_id == " "){$club_id = $default;}elseif(isset($club_id)){$club_id = $club_id;} ?>
<?php include ("$club_id"); ?>

<a href="?id=blah.Html">Venue 1</a>


Is there supposed to be something in the if($club_id == " ") ???? I can't get the link to blah.Html to open (I did create blah.Html)

Any help would be appreciated!
Jviney

-question by jviney

 

 

 


Reply

Framp
Include also evaluate the php code inside :/
It may be harmful for your server

I suggest you to use echo file_get_contents($page) instead

Reply

Erdemir
This is yours;
QUOTE(KansukeKojima @ Nov 10 2007, 02:16 AM) *
CODE
<?php $default = "blah.html"; if($id == ""){$id = $default;}elseif(isset($id)){$id = $id;} ?>
<?php include ("$id"); ?>


What about this?
CODE
<?php $default = "blah.html"; if(!$id){$id = $default;} ?>
<?php include ("$id"); ?>


Changes:
if(!$id) checks if $id is 0 or "" or null and there is no need of elseif(isset($id)){$id = $id;}

Reply

hitmanblood
Hey trap I suggest you to use method empty() if you would like to check whether variable is in fact empty. Because the code that you have pulled out:

CODE
if($id == ""){$id = $default;}elseif(isset($id)){$id = $id;}


in fact check if there is something in there that is equal to "" but if you haven't initialized variable $id then it will return always false. This is common mistake for the beginners with PHP.

So instead of: $id == "" you should put in empty($id)

tell me if this works.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. php id links - 7.82 hr back. (1)
  2. linking with php id - 53.52 hr back. (1)
  3. advantages of creating pages with php - 37.71 hr back. (2)
  4. /suggest-link.php?id= - 84.35 hr back. (1)
  5. advantages php - 85.78 hr back. (1)
  6. suggest-link.php - 88.53 hr back. (1)
  7. php linking text - 89.23 hr back. (1)
  8. php linking image - 114.77 hr back. (1)
  9. php linking - 131.60 hr back. (1)
  10. suggest-listing.php?id - 131.73 hr back. (1)
  11. suggest-listing.php - 135.47 hr back. (1)
  12. suggest-listing.php?id=0 - 87.16 hr back. (2)
  13. advantages of php - 158.36 hr back. (1)
  14. suggest/link.php - 182.80 hr back. (1)
Similar Topics

Keywords : php, linking, major, advantages, php, ability, create

  1. Prevent People From Linking To Your Downloads
    (5)
  2. Check Referrer To Prevent Linking Yours From Other Sites
    Check referrer with Php and Mysql (8)
    Check Referrer Using Php To Prevent People Linking To Your Downloads From Other Sites Ever
    find that found some people are listing items, images and tuts and linking directly to the download
    url (those that are like my photoshop tutorial.php?id=0), which is a .php to count the number of
    downloads. To prevent this, you can add a piece of code to the download pages that checks which page
    referred them to the download page: if it's my domain, it downloads the file normally, if
    it's not, it will redirect to my home page instead. Important : Not all browser....
  3. How To Stop Image Hot Linking
    for a selected directory. (17)
    Those of you that don't know what is meant by 'hotlinking', it is when someone directly
    links to an image on your site so it will display on their site. This is what is called
    'bandwidth theft' and being as accounts here have a limit on bandwidth, your bandwidth limit
    could be exceeded by someone else hotlinking to your images. As most users of cPanel will know,
    there is an option to disable hotlinking of images in the "Site Management Tools" section.
    However, this disables hotlinking to all directories, what if you only want to disable hotlinki....

    1. Looking for php, linking, major, advantages, php, ability, create

Searching Video's for php, linking, major, advantages, php, ability, create
advertisement



Php Linking - One of the major advantages of PHP is the ability to create something



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE