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 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2011
    Posts
    61
    Thanks
    9
    Thanked 1 Time in 1 Post

    Form not setting "GET" value

    I suppose the problem relates to HTML and not PHP however there is a tiny bit of PHP in the code which may have caused the problem:
    PHP Code:
    echo '<form action="index.php" method="get">';
    echo 
    '<select id="server">';
    if(
    $UserInfo->local_permissions == OR $UserInfo->admin_lvl >= 2){
        echo 
    '<option>Sandbox</option>';
    }
    if(
    $UserInfo->local_permissions == OR $UserInfo->admin_lvl >= 2){
        echo 
    '<option>Fretta</option>';
    }
    echo 
    '</select>&nbsp;';
    echo 
    'Day: <input type="text" id="day" maxlength="2" size="2" />&nbsp;';
    echo 
    'Month: <input type="text" id="month" maxlength="2" size="2" />&nbsp;';
    echo 
    'Year: <input type="text" id="year" maxlength="4" size="4" value="" />&nbsp;';
    echo 
    '<input type="hidden" id="page" value="logs" />';
    echo 
    '<input type="submit" value="Load" id="Load" /></form>'
    What you see here is an ordinary form... It works fine, until you click "Load"...
    What I think might be the sin here, is the fact that this piece of code is found on a page called "index.php?page=logs". When I press load it sends people to index.php as it's supposed to, but no data goes into the URL. This doesn't work with post either - and I really can't figure out what I've done wrong :S
    At first I tried setting the form action to index.php?page=logs and then after that I tried with just index.php and then saving the page variable inside the form.
    Last edited by Time Sheep; 12-21-2011 at 07:47 AM. Reason: Problem solved
    Need help?
    I work with the following languages:
    HTML: Professional - PHP: Professional - Visual C#: Average - CSS: Average - ASP: Please don't hurt me! ;(
    Currently practicing: Visual C#

  • #2
    Regular Coder Apothem's Avatar
    Join Date
    Mar 2008
    Posts
    380
    Thanks
    36
    Thanked 25 Times in 25 Posts
    You need a name for each form element. If there is no name, there is no key to associate the data to.

    e.g.
    Code:
    <select id="server" name="server">

  • Users who have thanked Apothem for this post:

    Time Sheep (12-21-2011)

  • #3
    New Coder
    Join Date
    Sep 2011
    Posts
    61
    Thanks
    9
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Apothem View Post
    You need a name for each form element. If there is no name, there is no key to associate the data to.

    e.g.
    Code:
    <select id="server" name="server">
    Oh... I thought id was a replacement for name...
    Well, thanks then :P Wouldn't have figured that out myself
    Need help?
    I work with the following languages:
    HTML: Professional - PHP: Professional - Visual C#: Average - CSS: Average - ASP: Please don't hurt me! ;(
    Currently practicing: Visual C#


  •  

    Tags for this Thread

    Posting Permissions

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