Jump to content

search_members.php problem, can't find the bug :(


Recommended Posts

ok,

my problem is in this script,

 

<h4 class="hl">Search member!</h4>
<?php
if(!$Submitsearch){
    echo "<div id=\"search\"><br />
         <form action=\"\"><input name=\"qmember\" type=\"text\" value=\"\" size=\"35\" />
             <input type=\"submit\" name=\"Submitsearch\" class=\"submit\" value=\"Search!\" />
          </form>
    </div>";
} else {
$searchmember = $_POST['qmember'];
$queryu = mysql_query("SELECT * FROM users WHERE username = '$searchmember' ORDER BY userid DESC");
$result = mysql_num_rows($queryu);
if(!$result){
echo  "sorry, no users found";
} else {
echo "<table class=\"users\">\n<tr>\n<td colspan=\"2\" class=\"tdusers\"><a href=\"/register\"> Register!</a></td>\n<td colspan=\"3\" class=\"tdusers\"><a href=\"/profile\">user list</a></td>\n</tr>\n</table>\n<table class=\"users\">\n<tr>\n<td class=\"topusers\" width=\"30px\">ID</td>\n<td class=\"topusers\" width=\"100px\">Avatar\n</td><td class=\"topusers\">Username</td>\n<td class=\"topusers\">Class</td>\n<td class=\"topusers\">Points</td>\n</tr>\n
";
while($object = mysql_fetch_object($queryu)){
if($object->level == 1){
  $class = member;
  }
if($object->level == 9){
  $class = admin;
  }
echo "<tr>\n<td class=\"tdusers\"> $object->userid </td>\n<td class=\"tdusers\"><image height=\"70\" width=\"70\" src=\"$object->avatar\" /></td>\n<td class=\"tdusers\"><a href=\"profile&user=$object->username\">$object->username</a></td>\n<td class=\"tdusers\">$class</td>\n<td class=\"tdusers\"> 0 </td>\n</tr>\n";
}
echo "</table>\n";
}
}
?>

 

this script is trying to search a member,

if i use this script, nothing happens, but you can see the search-box :P

 

thanks you!

Hi,

 

Unless you have register_globals switched on (which is a bad idea anyway), the value of $Submitsearch will not have been set even when the form has been submitted. Replace the first if statement with the following and see what happens:

 

if (!isset ($_POST['Submitsearch']))
{
   echo "<form .... etc>";
}
else
{
   // Process form.
}

 

Let me know how that works out for ya, and if its still not working I'll scrutinize it a bit more.

 

Cheers,

Darren.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.