PHP anchors

  • theBruney
  • Student
  • Student
  • User avatar
  • Joined: May 30, 2007
  • Posts: 67
  • Loc: China
  • Status: Offline

Post March 22nd, 2008, 10:22 am

Hello there,

This might seem like a silly question, but I've always wondered so I'll ask anyways. 8) How are these sort of anchors obtained: index.php?content=login, usually, one might see something like login.php. The forum anchors are like this also: posting.php?mode=post&f=33

I'm wondering because it it seems with some particular function or functions, can allow many php snippets to be embedded into the main file, that could be the index.php without having to duplicate the basic html/css template and then adding the include() function into those the templates.

Check this site out: http://www.metroairvirtual.com/

If you look at the main nav area, and hover over the links using a Firefox browser, (maybe IE 7 does this too) you'll see that all anchors are like: index.php?content=join, index.php?content=stats, index.php?content=hubs and so on. Now looking at the source code of the index.php, there are no include() functions, and I don't see any GET methods from forms (I think they produce similar anchors).

This method seems very convenient. Any links tutorials will be appreciated.

Thanks
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 22nd, 2008, 10:22 am

  • Sumen
  • Proficient
  • Proficient
  • User avatar
  • Joined: Jun 10, 2004
  • Posts: 418
  • Loc: Rochester or Albany, NY
  • Status: Offline

Post March 22nd, 2008, 6:12 pm

I may not be understanding the question correctly but...
When you use the url posting.php?mode=post&f=33
when posting.php is parsed $_GET["mode"] will equal "post" and $_GET["f"] will equal "33"
You do not need forms for this to be the case
also $QUERY_STRING will equal "mode=post&f=33"

Then it would be as easy as having conditionals depending on the values of the variables
  • theBruney
  • Student
  • Student
  • User avatar
  • Joined: May 30, 2007
  • Posts: 67
  • Loc: China
  • Status: Offline

Post March 22nd, 2008, 7:16 pm

Hmm. Don't need forms? Interesting. Do you know any links that'd be able to point me to this topic? I've been googling the $_GET method but the results are connected to forms.


Thanks Sumen. :)
  • markusPHP
  • Beginner
  • Beginner
  • User avatar
  • Joined: Mar 23, 2008
  • Posts: 44
  • Loc: york, england
  • Status: Offline

Post March 23rd, 2008, 12:38 am

The POST option is generally used more than GET in forms. What GET is good for is passing parameters through URLS. I.E, you have a link to a login page (login.php), but this link will be used for a confirmation page - so to avoid having a new page for a confirmation you just add an action to the URL (login.php?action=confirm).
The on login page you retrieve the action ($_GET['action']) and then run the relevant processes.

Regards :)
  • theBruney
  • Student
  • Student
  • User avatar
  • Joined: May 30, 2007
  • Posts: 67
  • Loc: China
  • Status: Offline

Post March 23rd, 2008, 6:27 am

Thanks sweetie pie. I got it! Hehehehehehe. I'm so happy. I don't know if what I did was the most convenient way to go, but anyhow I basically created a workman.php file and then put all the required conditional statements in the file:

Code: [ Download ] [ Select ]
<?php
if ($_GET['content'] == "ourstaff"){
include 'ourstaff.php';
}

else if ($_GET['content']=="ourairline"){
include 'ourairline.php';
}

else {
include 'ourairline.php';
}

?>
  1. <?php
  2. if ($_GET['content'] == "ourstaff"){
  3. include 'ourstaff.php';
  4. }
  5. else if ($_GET['content']=="ourairline"){
  6. include 'ourairline.php';
  7. }
  8. else {
  9. include 'ourairline.php';
  10. }
  11. ?>


Then just gave two links the following urls:
    index.php?content=ourstaff
    index.php?content=ourairline

I included the workman.php where I wanted the documents (ourstaff and ourairline) to appear in the index.php file and it worked just fine.

If there's a cleaner way someone can point out to me, but until then, this is what I can come up with.

Thanks!

:)
  • theBruney
  • Student
  • Student
  • User avatar
  • Joined: May 30, 2007
  • Posts: 67
  • Loc: China
  • Status: Offline

Post March 23rd, 2008, 8:06 am

PHP is such a wonderful thing. Just needed to say that. :D

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 164 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2010 Unmelted, LLC. Driven by phpBB © 2010 phpBB Group.