...

View Full Version : GET problem



graham23s
08-29-2007, 08:20 PM
Hi Guys,

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


//=============================================================================//
// 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:


userlist.php?search%3E=graham23s

in the address bar when searching any help would be appreciated

Graham

mlseim
08-29-2007, 08:33 PM
untested ... but something like this ....



<?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>
";

}

?>

rafiki
08-29-2007, 08:34 PM
you have an extra >
name=\"search>\">
and yes you missed the value of your hidden action part of the form

graham23s
08-29-2007, 09:11 PM
ah got it thanks guys.

Graham



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum