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 4 of 4

Thread: GET problem

  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    134
    Thanks
    12
    Thanked 0 Times in 0 Posts

    GET problem

    Hi Guys,

    in this simple bit of code im allowing users to search other users by name:

    PHP Code:
            //=============================================================================//
            // User search
            //=============================================================================//
            
    echo ("<h1>Search Users</h1>");
            echo (
    "<form method=\"get\" action=\"userlist.php\">Search For: <input type=\"hidden\" name=\"action\"><input type=text size=\"30\" name=\"search>\">");
            echo (
    "<input type=submit value='Search User'>");
            echo (
    "</form>");
            
            
    //=============================================================================//
            // The GET code
            //=============================================================================//  
            
    if ($_GET['action'] == "search") {
            
            echo 
    'search code here';
            
            
            } 
    but the get action doesnt seem to be right im getting:

    PHP Code:
    userlist.php?search%3E=graham23s 
    in the address bar when searching any help would be appreciated

    Graham

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,464
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    untested ... but something like this ....

    PHP Code:
    <?php
    if($_POST['action'] === "search"){

    // search code here
    $target $_POST['search'];

    }
    else{
    echo
    "
    <h1>Search Users</h1> 
    <form action='userlist.php' method='post' \>
    <input type='hidden' name='action' value='search' \>
    Search For: <input type='text' size='30' name='search' \> 
    <input type='submit' value='Search User'>
    </form>
    "
    ;

    }

    ?>

  • #3
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    you have an extra >
    name=\"search>\">
    and yes you missed the value of your hidden action part of the form
    Last edited by rafiki; 08-29-2007 at 07:38 PM.

  • #4
    Regular Coder
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    134
    Thanks
    12
    Thanked 0 Times in 0 Posts
    ah got it thanks guys.

    Graham


  •  

    Posting Permissions

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