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 15 of 15
  1. #1
    Regular Coder
    Join Date
    Jul 2008
    Posts
    195
    Thanks
    3
    Thanked 11 Times in 11 Posts

    New To PHP- Please Help

    I. I have a set of pages named:
    order.php@level=10
    order.php@level=20
    order.php@level=30
    ect...

    However, my pages link to:
    order.php?level=10
    order.php?level=20
    order.php?level=30
    ect...

    Thus, the pages are not found.

    If I try and rename the pages to:
    order.php?level=10
    order.php?level=20
    order.php?level=30
    ect...

    I get an error saying that "?" is not a valid filename character.

    If I change the links to:
    order.php@level=10
    order.php@level=20
    order.php@level=30
    ect...

    The source code is displayed, and the page isn't rendered.

    Please help.

    Thank you very much!

  • #2
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    You create one page named order.php and then get the level via $_GET['level'] ... you don't create pages with the parameters..

  • #3
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,039
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Thats because the filenames are order.php the ? indicates that there is a variable attached to the url. You must have PHP installed on the server or it will show the source code or ask you to download the file.
    I suggest you read some tutorials.
    Edit:
    Just beaten to it

  • #4
    Regular Coder
    Join Date
    Jul 2008
    Posts
    195
    Thanks
    3
    Thanked 11 Times in 11 Posts

    Paramenters

    Quote Originally Posted by Iszak View Post
    You create one page named order.php and then get the level via $_GET['level'] ... you don't create pages with the parameters..
    Where do the parameters do than?

    Thanks again.

  • #5
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    Well you'll create the file say.

    order.php
    PHP Code:
    <?php
    echo $_GET['level'];
    ?>
    then to add parameters you'll make links to the page like order.php?parameter=value in your case order.php?level=10 and if you use the echo sample I showed it'll output the value 10.. or atleast its should..

  • #6
    Regular Coder
    Join Date
    Jul 2008
    Posts
    195
    Thanks
    3
    Thanked 11 Times in 11 Posts
    So:
    PHP Code:
    <?php
    echo $_GET['level'];
    ?>
    OK, but how do I set each level? This just says that I am using level as a parameter. Different levels should show different options on the page.

  • #7
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    Well in that case it'll be like
    PHP Code:
    <?php

    if ($_GET['level'] == 10)
    {
      
    // Do something for level 10
    }

    elseif (
    $_GET['level'] == 20)
    {
      
    // Do something for level 20
    }
    // etc
    else
    {
      
    // Level not valid
    }

    ?>

  • #8
    Regular Coder
    Join Date
    Jul 2008
    Posts
    195
    Thanks
    3
    Thanked 11 Times in 11 Posts

    Parameters

    Quote Originally Posted by Iszak View Post
    Well in that case it'll be like
    PHP Code:
    <?php

    if ($_GET['level'] == 10)
    {
      
    // Do something for level 10
    }

    elseif (
    $_GET['level'] == 20)
    {
      
    // Do something for level 20
    }
    // etc
    else
    {
      
    // Level not valid
    }

    ?>
    OK. So, each page shows different content, and when you press Order, it brings you to a page to purchase what was displayed on the page.

    Where do I say what contect each level shows?

    Example (hosting)
    order.php?level=10
    Space: 10GB
    Bandwidth: 100GB/monthly
    Price: $10/month

    order.php?level=20
    Space: 20GB
    Bandwidth: 200GB/monthly
    Price: $20/month

    order.php?level=30
    Space: 30GB
    Bandwidth: 300GB/monthly
    Price: $30/month

    Where each of those options shows on their respective parameter.

  • #9
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    Well if you're using a button you can use the form e.g.
    Code:
    <form action="order.php" method="GET">
      <input type="hidden" name="level" value="10" />
      <input type="submit" value="Order" />
    </form>
    and then it'll pass the value level to the order page.. or you could use post..
    alternatively you could use

    Code:
    <form action="order.php?level=10">
      <input type="submit" value="Order" />
    </form>
    this is implying you'll have 1 for each order button..


    Full example
    Code:
    Space: 10GB
    Bandwidth: 100GB/monthly
    Price: $10/month
    <form action="order.php?level=10">
      <input type="submit" value="Order" />
    </form>
    <br />
    <br />
    
    Space: 20GB
    Bandwidth: 200GB/monthly
    Price: $20/month
    <form action="order.php?level=20">
      <input type="submit" value="Order" />
    </form>
    <br />
    <br />
    
    Space: 30GB
    Bandwidth: 300GB/monthly
    Price: $30/month
    <form action="order.php?level=30">
      <input type="submit" value="Order" />
    </form>
    Last edited by Iszak; 07-15-2008 at 10:21 PM.

  • #10
    Regular Coder
    Join Date
    Jul 2008
    Posts
    195
    Thanks
    3
    Thanked 11 Times in 11 Posts

    Example

    I got the idea from here:

    http://parentchild411.com/advertise.php


    That is exactly what I need. You will see when you click on Order Now what I mean.

  • #11
    New Coder
    Join Date
    Jul 2008
    Posts
    99
    Thanks
    0
    Thanked 4 Times in 4 Posts
    macwiz, they are simply using a link... like:

    <a href="order.php?level=10"><img src="imagehere.jpg" /></a> <----(they are not doing it exactly like that, but you get the point)

    Then you would retrieve the variable like Iszak said, with the GET method.
    Last edited by ramm19; 07-15-2008 at 10:58 PM.

  • #12
    Regular Coder
    Join Date
    Jul 2008
    Posts
    195
    Thanks
    3
    Thanked 11 Times in 11 Posts

    Parameters

    Quote Originally Posted by ramm19 View Post
    macwiz, they are simply using a link... like:

    <a href="order.php?level=10"><img src="imagehere.jpg" /></a> <----(they are not doing it exactly like that, but you get the point)

    Then you would retrieve the variable like Iszak said, with the GET method.
    But that is where I get stuck again. How could I do it like they did?

    Take a look at the source of:
    http://www.parentchild411.com/advertise.php

    not once does it have anything like <?php or echo

  • #13
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,039
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Because the echo ""; statement is processed before the html and add's to the markup, after all it is a Server Side Language.

  • #14
    Regular Coder
    Join Date
    Jul 2008
    Posts
    195
    Thanks
    3
    Thanked 11 Times in 11 Posts
    Quote Originally Posted by rafiki View Post
    Because the echo ""; statement is processed before the html and add's to the markup, after all it is a Server Side Language.
    Is there a way to view the PHP file plain, as in before the server processes it?

  • #15
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,039
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Not unless you have access to the server it will be processed on for security.


  •  

    Posting Permissions

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