hmm, ja det fikk jeg til.. men jeg lurer på en ting til.. på denne siden (admin siden) så vises ALLE brukerne når en logger seg inn.. det vil jeg ha bort.. men tar jeg det bort, vises ikke noe når en søker heller.. kan noen hjelpe meg her? poster koden..
koden er delt i to..
Kode
<?php
//prevents caching
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter();
session_start();
require('../config.php');
require('../functions.php');
//check for administrative rights
if (allow_access(Administrators) != "yes")
{
include ('../no_access.html');
exit;
}
//make connection to dbase
$connection = @mysql_connect($server, $dbusername, $dbpassword)
or die(mysql_error());
$db = @mysql_select_db($db_name,$connection)
or die(mysql_error());
//build and issue the query
$sql ="SELECT * FROM $table_name";
$result = @mysql_query($sql,$connection) or die(mysql_error());
?>
<head>
<meta http-equiv="Content-Language" content="en-us">
<link rel="stylesheet" type="text/css" href="adminpage.css">
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
<table border="0" width="100%" id="table1">
<tr>
<td align="center">
<table border="0" width="800" id="table2" cellspacing="0" cellpadding="0">
<tr>
<td width="280"> </td>
<td> </td>
</tr>
<tr>
<td width="280"><b><font size="2">Login - Redirect Control Panel</font></b></td>
<td align="right"><i><a href="../logs/index.php">View Access Logs</a></i></td>
</tr>
<tr>
<td width="280">Logged in as <?php echo $_SESSION[user_name]; ?></td>
<td align="right"><i><a href="../logout.php">Logout</a></i></td>
</tr>
<tr>
<td width="280"> </td>
<td>
<p align="right"><i><a href="mail_all.htm">Email All Users</a></i></td>
</tr>
<tr>
<td width="280" valign="top">
<table border="0" width="100%" id="table3" cellspacing="0" cellpadding="0">
<tr>
<td width="38%" valign="top">
<table border="0" width="100%" id="table38" cellspacing="0" cellpadding="0">
<tr>
<td>
<?php
if ($_POST[alter2] == "add")
{
?>
<form method="POST" action="<?php $PHP_SELF; ?>">
<p><input type="hidden" name="alterup2" value="up"><input type="image" img src="admin_add_up.gif" value="Submit" alt="Submit"></p>
</form>
<?php
}else
{
?>
<form method="POST" action="<?php $PHP_SELF; ?>">
<p><input type="hidden" name="alter2" value="add"><input type="image" img src="admin_add.gif" value="Submit" alt="Submit"></p>
</form>
<?php
}
?>
</td>
</tr>
<tr>
<td>
<?php
if ($_POST[alter2] == "add")
{
?>
<form method="POST" action="<? echo "adduser.php?page=$page&max_results=$max_results"; ?>">
<font size="1" face="Tahoma">
<table border="1" width="100%" id="table44" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF">
<tr>
<td width="140">First Name:</td>
<td><font size="1" face="Tahoma">
<input type="text" name="firstname" size="20"></font></td>
</tr>
<tr>
<td width="140">Last Name:</td>
<td><font size="1" face="Tahoma">
<input type="text" name="lastname" size="20"></font></td>
</tr>
<tr>
<td width="140">Username:</td>
<td><font size="1" face="Tahoma">
<input type="text" name="username" size="20"></font></td>
</tr>
<tr>
<td width="140">Password:</td>
<td><font size="1" face="Tahoma">
<input type="text" name="password" size="20" maxlength="667"></font></td>
</tr>
<tr>
<td width="140">E-Mail Address:</td>
<td><font size="1" face="Tahoma">
<input type="text" name="email" size="20"></font></td>
</tr>
<tr>
<td width="140">Group Memberships:</td>
<td><font size="1" face="Tahoma">
<select size="1" name="group1">
<?php
echo "<option>Users</option>";
$i = 0;
while ($i < $num_groups)
{
echo "<option value=\"$group_array[$i]\">$group_array[$i]</option>";
$i++;
}
?>
</select></font></td>
</tr>
<tr>
<td width="140"> </td>
<td><font size="1" face="Tahoma">
<select size="1" name="group2">
<?php
echo "<option></option>";
$i = 0;
while ($i < $num_groups)
{
echo "<option value=\"$group_array[$i]\">$group_array[$i]</option>";
$i++;
}
?>
</select></font></td>
</tr>
<tr>
<td width="140"> </td>
<td><font size="1" face="Tahoma">
<select size="1" name="group3">
<?php
echo "<option></option>";
$i = 0;
while ($i < $num_groups)
{
echo "<option value=\"$group_array[$i]\">$group_array[$i]</option>";
$i++;
}
?>
</select></font></td>
</tr>
<tr>
<td width="140">Redirect to:</td>
<td><font size="1" face="Tahoma">
<input type="text" name="redirect" size="20" value="http://"></font></td>
</tr>
<tr>
<td width="140">Change Password Next Login:</td>
<td><font size="1" face="Tahoma">
<select size="1" name="pchange">
<option value="0" selected>No</option>
<option value="1">Yes</option>
</select></font></td>
</tr>
<tr>
<td width="140">E-Mail User Account
Information:</td>
<td><font size="1" face="Tahoma">
<select size="1" name="email_user">
<option value="No" selected>No</option>
<option value="Yes">Yes</option>
</select></font></td>
</tr>
<tr>
<td width="140"><font size="1" face="Tahoma">
<input type="submit" value="Submit" name="B4"></font></td>
<td> </td>
</tr>
</table>
</font>
</td>
</tr>
<tr>
</form>
<?php
}
?>
</tr>
<tr>
<td><font size="1" face="Tahoma">
<?php
if ($_POST[alter1] == "modify" || $_POST[username] != "")
{
?>
<form method="POST" action="<? $PHP_SELF; ?>">
<p>
<input type="hidden" name="alter1" size="20" value="up"><input type="image" img src="admin_mod_up.gif" value="Submit" alt="Submit"></p>
</form>
<?php
}
else{
?>
<form method="POST" action="<? $PHP_SELF; ?>">
<p>
<input type="hidden" name="alter1" size="20" value="modify"><input type="image" img src="admin_mod.gif" value="Submit" alt="Submit"></p>
</form>
<?php
}
?>
</td>
<?
if (($_POST[alter1] == "modify") || ($_POST[username] != ""))
{
?>
<tr>
<td>
<font size="1" face="Tahoma">
<form name="myform" id="myform" action="<? $PHP_SELF; ?>" method="POST">
<table border="1" width="100%" id="table41" cellspacing="0" cellpadding="0" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF">
<tr>
<td width="140">Username:</td>
<td><font size="1" face="Tahoma">
<select size="1" name="username" onChange="document.myform.submit()">
<?
if ($_POST[username] != "")
{
echo "<option>$_POST[username]</option>";
echo "<option value=\"\"></option>";
}
else
{
echo "<option></option>";
}
//require the config file
require ("../config.php");
//make the connection to the database
$connection = @mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error());
$db = @mysql_select_db($db_name,$connection)or die(mysql_error());
//build and issue the query
$sql ="SELECT * FROM $table_name";
$result = @mysql_query($sql,$connection) or die(mysql_error());
while ($sql = mysql_fetch_object($result))
{
$uname = $sql -> username;
echo "<option value=\"$uname\">$uname</option>";
}
?>
</select></font></td>
</tr>
</table>
</form>
</font>
</td>
</tr>
<?php
if ($_POST[username] != "")
{
//require the config file
require ("../config.php");
//make the connection to the database
$connection = @mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error());
$db = @mysql_select_db($db_name,$connection)or die(mysql_error());
//build and issue the query
$sql ="SELECT * FROM $table_name WHERE username = '$_POST[username]'";
$result = @mysql_query($sql,$connection) or die(mysql_error());
while ($sql = mysql_fetch_object($result))
{
$m_first = $sql -> firstname;
$m_last = $sql -> lastname;
$g_1 = $sql -> group1;
$g_2 = $sql -> group2;
$g_3 = $sql -> group3;
$chng = $sql -> pchange;
$m_email = $sql -> email;
$direct = $sql -> redirect;
}
?>
<tr>
<td>
<form method="POST" action="mod_user.php">
<font size="1" face="Tahoma">
<table border="1" width="100%" id="table1" cellspacing="0" cellpadding="0" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF">
<tr>
<td width="140">First Name:</td>
<td><font size="1" face="Tahoma">
<input type="hidden" name="username" value="<? echo $_POST[username]; ?>">
<input type="text" name="mod_first" value="<? echo $m_first; ?>" size="20"></font></td>
</tr>
<tr>
<td width="140">Last Name:</td>
<td><font size="1" face="Tahoma">
<input type="text" name="mod_last" value="<? echo $m_last; ?>" size="20"></font></td>
</tr>
<tr>
<td width="140">
Password:</td>
<td><font size="1" face="Tahoma">
<input type="text" name="mod_pass" size="20" value="Same as Old"></font></td>
</tr>
<tr>
<td width="140">
E-Mail Address:</td>
<td><font size="1" face="Tahoma">
<input type="text" name="mod_email" value="<? echo $m_email; ?>" size="20"></font></td>
</tr>
<tr>
<td width="140">
Group Memberships:</td>
<td><font size="1" face="Tahoma">
<select size="1" name="mod_group1">
<?php
echo "<option>$g_1</option>";
$i = 0;
while ($i < $num_groups)
{
echo "<option value=\"$group_array[$i]\">$group_array[$i]</option>";
$i++;
}
?>
</select></font></td>
</tr>
<tr>
<td width="140">
</td>
<td><font size="1" face="Tahoma">
<select size="1" name="mod_group2">
<?php
echo "<option>$g_2</option>";
$i = 0;
while ($i < $num_groups)
{
echo "<option value=\"$group_array[$i]\">$group_array[$i]</option>";
$i++;
}
?>
</select></font></td>
</tr>
<tr>
<td width="140">
</td>
<td><font size="1" face="Tahoma">
<select size="1" name="mod_group3">
<?php
echo "<option>$g_3</option>";
$i = 0;
while ($i < $num_groups)
{
echo "<option value=\"$group_array[$i]\">$group_array[$i]</option>";
$i++;
}
?>
</select></font></td>
</tr>
<tr>
<td width="140">
Redirect to:</td>
<td><font size="1" face="Tahoma">
<input type="text" name="mod_redirect" value="<? echo $direct; ?>" size="20"></font></td>
</tr>
<tr>
<td width="140">
Change Password Next Logon:</td>
<td><font size="1" face="Tahoma">
<select size="1" name="mod_chng">
<option value="0" selected>No</option>
<option value="1">Yes</option>
</select></font></td>
</tr>
<tr>
<td width="140">
E-Mail User Account Information:</td>
<td><font size="1" face="Tahoma">
<select size="1" name="mod_send">
<option value="No" selected>No</option>
<option value="Yes">Yes</option>
</select></font></td>
</tr>
<tr>
<td width="140">
<font size="1" face="Tahoma">
<input type="submit" value="Submit" name="B5"></font></td>
<td> </td>
</tr>
</table>
</font>
</form>
</td>
</tr>
<?php
}
?>
<?
}
?>
</td>
</tr>
<tr>
<td width="38%">
<?php
if ($_POST[alter] == "options")
{
?>
<form method="POST" action="<?php $PHP_SELF; ?>">
<p>
<input type="hidden" name="alter" value="up">
<input type="image" src="admin_options_up.gif" value="Submit" alt="Submit"></p>
</form>
<?php
}
else
{
?>
<form method="POST" action="<?php $PHP_SELF; ?>">
<p>
<input type="hidden" name="alter" value="options">
<input type="image" src="admin_options.gif" value="Submit" alt="Submit"></p>
</form>
<?php
}
?>
</td>
</tr>
<tr>
<td width="33%" valign="top" height="0">
<?php
if ($_POST[alter] == "options")
{
?>
<form method="POST" action="mod_user.php">
<table border="1" width="100%" id="table43" cellspacing="0" cellpadding="0" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF">
<tr>
<td width="140">Delete User</td>
<td>
<font size="1" face="Tahoma">
<select size="1" name="del_user">
<option></option>
<?php
//require the config file
require ("../config.php");
//make the connection to the database
$connection = @mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error());
$db = @mysql_select_db($db_name,$connection)or die(mysql_error());
//build and issue the query
$sql ="SELECT username FROM $table_name ORDER BY username";
$result = @mysql_query($sql,$connection) or die(mysql_error());
while ($sql = mysql_fetch_object($result))
{
$uname = $sql -> username;
if ($uname != $_SESSION[user_name])
{
echo "<option value=\"$uname\">$uname</option>";
}
}
?>
</select></font></td>
</tr>
<tr>
<td width="140">Restore User</td>
<td>
<font size="1" face="Tahoma">
<select size="1" name="restore">
<option></option>
<?php
//require the config file
require ("../config.php");
//make the connection to the database
$connection = @mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error());
$db = @mysql_select_db($db_name,$connection)or die(mysql_error());
//build and issue the query
$sql ="SELECT username FROM trash ORDER BY username";
$result = @mysql_query($sql,$connection) or die(mysql_error());
while ($sql = mysql_fetch_object($result))
{
$uname = $sql -> username;
if ($uname != $_SESSION[user_name])
{
echo "<option value=\"$uname\">$uname</option>";
}
}
?>
Sist endret av jorni; 7. oktober 2007 kl. 19:07.