Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7

Thread: url appear id

  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    url appear id

    Hi everyone i want to appear my link on the adressbar when i click any link like this:
    PHP Code:
    http://www.domain.com/get-file.php?id=1 
    E.g my contact link appears like this:
    PHP Code:
    http://www.domain.com/contact.php 
    here are what i did:
    get-file.php

    PHP Code:
    <?php

    // get-file.php
    // call with: http://domain/get-file.php?id=1

    $id = (isset($_GET["id"])) ? strval($_GET["id"]) : "1";

    // lookup
    $url[1] = 'http://www.domain.com/contact.php';

    header("Location: $url[$id]");
    exit;

    ?>
    link code:
    PHP Code:
    <a href='http://www.domain.com/get-file.php?id=1'>Contact Us</a

    Can someone help me the right code?
    thanks everybody.

  • #2
    New Coder
    Join Date
    Mar 2009
    Posts
    43
    Thanks
    2
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?
    $id 
    $_GET['id']; //you should only allow numbers

    If ($_GET['id']==1){
    $file $map.'page1.php'//this says what the id is
    }
    else If (
    $_GET['id']== 2){
    $file $map.'page2.php';
    }
    else If (
    $_GET['id'] == 3){
    $file $map.'page3.php';
    }
    else If (
    $_GET['id'] == 4){
    $file $map.'page4.php';
    }
    else {
    $file $map.'page0.php';
    }

    include(
    $file ); //includes the document the link asked for.
    ?>
    NOT BY ME!!

    Source: Click

  • #3
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanks alot Pandabeer for your right code i works fine and give 1000 thanks

  • #4
    New Coder
    Join Date
    Mar 2009
    Posts
    43
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by dalka View Post
    Thanks alot Pandabeer for your right code i works fine and give 1000 thanks
    dont thank me thank the creator of that tut

  • #5
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    You could also do..
    PHP Code:
    <?php

    $id   
    $_GET['id'];
    $file $map;

    switch (
    $id)
    {
      case 
    1:
        
    $file .= 'page1.php';
      break;

      case 
    2:
        
    $file .= 'page2.php';
      break;

      case 
    3:
        
    $file .= 'page3.php';
      break;

      case 
    4:
        
    $file .= 'page4.php';
      break;

      default:
        
    $file .= 'page4.php';
      break;
    }

    include 
    $file;
    You could even do...
    PHP Code:
    <?php

    $id   
    $_GET['id'];

    if (
    is_readable($map.'page'.$id.'php') === true)
    {
      
    // File can't be read / found
      
    include $file;
    }

    else
    {
      
    // Default page
      
    include $map.'page'.$id.'php';
    }
    Last edited by Iszak; 03-09-2009 at 08:33 PM.

  • #6
    New Coder
    Join Date
    Mar 2009
    Posts
    43
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Iszak View Post
    You could also do..
    PHP Code:
    <?php

    $id   
    $_GET['id'];
    $file $map;

    switch (
    $id)
    {
      case 
    1:
        
    $file .= 'page1.php';
      break;

      case 
    2:
        
    $file .= 'page2.php';
      break;

      case 
    3:
        
    $file .= 'page3.php';
      break;

      case 
    4:
        
    $file .= 'page4.php';
      break;

      default:
        
    $file .= 'page4.php';
      break;
    }

    include 
    $file;
    You could even do...
    PHP Code:
    <?php

    $id   
    $_GET['id'];

    if (
    is_readable($map.'page'.$id.'php') === true)
    {
      
    // File can't be read / found
      
    include $file;
    }

    else
    {
      
    // Default page
      
    include $map.'page'.$id.'php';
    }
    maybe your page's name isn't page[1-10]

  • #7
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    I was only using the way you were using Pandabeer, it's not hard to edit it especially the 2nd way.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •