Jump to content


Photo

generating pages with custom strings as urls


  • Please log in to reply
4 replies to this topic

#1 tomjones

tomjones
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 17 July 2006 - 08:54 PM

Hi,

I would like to know how to generate pages such as www.domain.com/file.php?12345 or www.domain.com/file.php?678910.

Any advice or links appreciated. Thank you.

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 July 2006 - 09:00 PM

look at $_GET[' '] ok.


test.php
<?
echo"<a href='test_result.php?php=freaks'>go to page</a>";
?>


test_result.php
<?
if(!$_GET['php']=='freaks') {

do somthink

}
?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 tomjones

tomjones
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 17 July 2006 - 09:25 PM

I did not see the correlation when experimenting with the above example. More specific I am trying to generate pages with custom names from an array, like www.domain.com/page.php?foo1 and www.domain.com/page.php?foo2. I Just need to know how to create these urls with php.. thanks.

#4 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 17 July 2006 - 09:33 PM

may be a switch statement is what you are wanting.

<?php
function getpage($showpage) {
    switch ($showpage) {
        case "your_page":
//put the php here
        break;
        case "your_next_page":
//put another page here
        break;
    default:
//your default page
    }
}
getpage($_GET['showpage']);//you need this to execute your code
?>

A link for this would be whatever.php?showpage=your_page


Hope that helps

Tom

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#5 pixy

pixy
  • Members
  • PipPipPip
  • Advanced Member
  • 295 posts

Posted 17 July 2006 - 09:36 PM

^ It's exactly what redarrow said.

You use the $_GET superglobal to track what link to go to. Example:

if (isset($_GET['link'])) {
   $link = $_GET['link'];
   if ($link == 3) {
       // Include links for page.php?link=3
   }
   elseif ($link == 5) {
       // page.php?link=5
   }
   else {
       die ('You are not using a valid link');
   }
}
else {
   // Show page.php
}

You can repeat the elseif statement for however many you want different stuff to show up. There are many ways of using the $_GET superglobal to create those kinds of links.

This is a .44 Caliber Loveletter straight through my heart.

Tabulas + Threadless + Hire Me!





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users