اينم كد صفجه
<?php
session_start();
//require('main_fns.php');
function show()
{
$conn = db_connect() or die("Can not Connect to the Database");
$query="SELECT * from users order by username";
$result=mysql_query($query);
if(!$result)
{
print("Error, Can not Connect to the database");
die();
}
$num=mysql_num_rows($result);
$i=0;
for($i=0;$i<$num;$i++)
{
$row=mysql_fetch_row($result);
//$color[];
echo'<tr>';
//if ($i)
//{
echo"<td align=\"center\"><font color=\"#000000\"><b>".strtoupper($row[0])."</b></font></td>";
echo"<td align=\"center\"><font color=\"#000000\"><b>$row[2]</b></font></td>";
echo"<td align=\"center\"><a href=\"$row[6]\"><b>Download</b></a></td>";
echo"<td> </td>";
echo"<td> </td>";
echo"<td> </td>";
//}
// else
//{
//echo"<td align=\"center\"><font color=\"#000000\"><b>$row[2]</b></font></td>";
// }
echo'</tr>';
}
echo"<tr><td align=\"center\"><b>Count=$num</b></td></tr>";
mysql_close();
echo'</table>';
echo'</center>';
}
//---------------------------------------------------------------
function error_message($msg)
{
echo"<script>alert(\"Error:$msg\")</script>";
exit;
}
//-------------------------------------------------------------------
function search($field,$q,$filter)
{ $query="select * from users where username like %'a'";
if ($filter)
{
//$query="SELECT * FROM users where username like"."'%$filter'";
/*switch($field)
{
case "name":
error_message($filter);
//$query="SELECT * FROM users where username like %'$filter'";
break;
case "email":
error_message('1');
$query="SELECT * FROM users where email like %'$filter'";
break;
default:
error_message('2');
$query="SELECT * FROM users where username='$q'";
}*/
}
else
{
error_message('else');
switch($field)
{
case "name":
error_message('3');
$query="SELECT * FROM users where username='$q'";
break;
case "email":
error_message('4');
$query="SELECT * FROM users where email='$q'";
break;
default:
error_message('5');
$query="SELECT * FROM users where username='$q'";
}
}
$conn = db_connect() or die("Can not Connect to the Database");
echo($query);
//$dt=date(YMJlHisA);
$result=mysql_query($query);
if (!$result)
error_message(" 1 !");
$num=mysql_num_rows($result);
if(!$num)
{
error_message(" Not Found !");
}
for($i=0;$i<$num;$i++)
{
$row=mysql_fetch_row($result);
echo'<tr>';
switch ($row[4])
{
case "1": echo"<td align=\"center\"><img src=\"images/stars-10.gif\"></td>"; break;
case "2": echo"<td align=\"center\"><img src=\"images/stars-20.gif\"></td>"; break;
case "3": echo"<td align=\"center\"><img src=\"images/stars-30.gif\"></td>"; break;
case "4": echo"<td align=\"center\"><img src=\"images/stars-40.gif\"></td>"; break;
case "5": echo"<td align=\"center\"><img src=\"images/stars-50.gif\"></td>"; break;
}
echo"<td align=\"center\"><font color=\"#000000\"><b>".strtoupper($row[0])."</b></font></td>";
echo"<td align=\"center\"><font color=\"#000000\"><b>$row[1]</b></font></td>";
echo"<td align=\"center\"><font color=\"#000000\"><b>$row[2]</b></font></td>";
echo"<td align=\"center\"><font color=\"#000000\"><b>".ucwords($row[3])."</b></font></td>";
echo"<td align=\"center\" bgcolor=\"#FFFF99\"><a href=\"$row[6]\"><b>Download</b></a></td>";
echo'</tr>';
}
echo"<tr><td align=\"center\"><font color=\"#000000\"><b>Count=$num</b></font></td></tr>";
mysql_close();
}//&&&&&&&&&&&&& END SEARCH &&&&&&&&&&&&&&&&&&
///do_html_header('');
///do_html_topbtn();
//do_html_heading('Search Usre');
$color=array("0"=>'#000000',"1"=>'#ffffff');
if(!isset($_SESSION['admin_user']))
{
error_message("You can not access in this page");
}
?>
<form action="finduser.php" method="post">
<table border="1" bgcolor="#000000" width=100%>
<tr>
<td width=9% align="center"><font color="#FFFFFF" ><b>Search User</b></font> </td>
<td width=9% align="center"> <select name="field">
<option value="name">Name
<option value="email">Email
</select></td>
<td align="center" bgcolor="#000000" >
<a href="finduser.php?filter=a" style="color:#FFFF00">A</a> <a href="finduser.php?filter=b" style="color:#FFFF00">B</a> <a href="finduser.php?filter=c" style="color:#FFFF00">C</a> <a href="finduser.php?filter=d" style="color:#FFFF00">D</a> <a href="finduser.php?filter=e" style="color:#FFFF00">E</a> <a href="finduser.php?filter=f" style="color:#FFFF00">F</a> <a href="finduser.php?filter=g" style="color:#FFFF00">G</a> <a href="finduser.php?filter=h" style="color:#FFFF00">H</a> <a href="finduser.php?filter=i" style="color:#FFFF00">I</a> <a href="finduser.php?filter=j" style="color:#FFFF00">J</a> <a href="finduser.php?filter=k" style="color:#FFFF00">K</a> <a href="finduser.php?filter=l" style="color:#FFFF00">L</a> <a href="finduser.php?filter=m" style="color:#FFFF00">M</a> <a href="finduser.php?filter=n" style="color:#FFFF00">N</a> <a href="finduser.php?filter=o" style="color:#FFFF00">O</a> <a href="finduser.php?filter=p" style="color:#FFFF00">P</a> <a href="finduser.php?filter=q" style="color:#FFFF00">Q</a> <a href="finduser.php?filter=r" style="color:#FFFF00">R</a> <a href="finduser.php?filter=s" style="color:#FFFF00">S</a> <a href="finduser.php?filter=t" style="color:#FFFF00">T</a> <a href="finduser.php?filter=u" style="color:#FFFF00">U</a> <a href="finduser.php?filter=v" style="color:#FFFF00">V</a> <a href="finduser.php?filter=w" style="color:#FFFF00">W</a> <a href="finduser.php?filter=x" style="color:#FFFF00">X</a> <a href="finduser.php?filter=y" style="color:#FFFF00">Y</a> <a href="finduser.php?filter=z" style="color:#FFFF00">Z</a> <a href="finduser.php?filter=all" style="color:#FFFF00">Other</a>
</td></tr>
<tr align="center" >
<td > <input name="query" type="text" size="10" ></td>
<td ><input type="submit" name="search" value=" Search " ></td>
<td bgcolor="#000000" style="color:#FFFF00"> Filter Tools:<input type="radio" name="Merge" />Merge
<input type="radio" name="Merge" />no Merge
<input type="button" name="apply" value=" Apply &n bsp; " />
</td>
</tr>
</table>
</form>
<p> </p>
<center>
<table width="90%" border=1>
<tr bgcolor="#000000">
<th width="17%" ><span style="color: #FFFF00">User Name</span></th>
<th width="20%"><span style="color: #FFFF00">E-mail</span></th>
<th width="2%"><span style="color: #FFFF00">Tools</span></th>
<th width="17%"><span style="color: #FFFF00">User Name</span></th>
<th width="20%"><span style="color: #FFFF00">E-mail</span></th>
<th width="2%"><span style="color: #FFFF00">Tools</span></th>
</tr>
<?php
$field=$_POST['field']; //select
$q=$_POST['query']; //value in textbox
$run=$_POST['search']; //search btn
$filter = $_GET['filter']; //a-z & other link
if (isset($_GET['filter']))
{
search($field,$q,$filter);
}
if(($q)&&($run))
{
$q=trim($q);
search($field,$q);
}
else if($filter)
search($field,$q,$filter);
else
show();
//if $filter
//display_admin_menu();
//display_button('admin.php', 'admin-menu', 'Admin Menu');
echo'</body>';
echo'</html>';
?>