arne
06-30-2006, 02:17 PM
:confused: What have i done wrong?
Sql won't update
Codes:
(connecting to database is done in config.php wich is included (no database connect problems, everything works on other pages).
Code (part 1)
if ($_GET['a'] == 'update')
mysql_query("UPDATE users SET status='".$_POST['userstatus']."',username='".$_POST['username']."',password='".$_POST['password']."',credit='".$_POST['credits']."',email='".$_POST['email']."',fullname='".$_POST['fullname']."',messenger='".$_POST['messenger']."',refferedby='".$_POST['refferedby']."' WHERE id='".$_POST['idkey']."'");
echo $_POST['idkey'];
(i added echo $_POST['idkey'] to see if that was filled in, and it was, i got the right id !
Here the form code:
$usercheck = mysql_query('SELECT * FROM users WHERE username="'.$_POST['username'].'"');
$num_rows = mysql_num_rows($usercheck);
if($num_rows == 0){
echo '<font color=red><b>User not found ! <br> You searched for '.$_POST['username'].'</b></font><br>';
echo"<br><br><br>
<a href='user.php'>Try Again</a>";
}else{
$query = "SELECT * FROM users WHERE username='".$_POST['username']."'";
$uitvoer = mysql_query($query) or die (mysql_error());
while($lijst = mysql_fetch_object($uitvoer))
{
echo "<form action='".$_SERVER['PHP_SELF']."?a=update' method='POST'>
<font size='4'><b>Editing user info</b></font><font> (user '".$_POST['username']."')</font><br><br>
<table width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr><td width='50%' height='24'><u>User</u></td>
<td width='50%' height='24'></td></tr></table>
<br><table width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr><td width='50%' height='24'>Unique ID</td>
<td width='50%' height='24'>$lijst->id</td><input type='hidden' name='idkey' value='$lijst->id'></td></tr></tr>
<tr>
<td width='50%' height='24'>User status</td>
<td width='50%' height='24'><select size='1' name='userstatus'>";
$usn=$_POST['username'];
if($lijst->status == 0){
$status=banned;
}elseif($lijst->status == 1){
$status=admin;
}elseif($lijst->status == 2){
$status=supporter;
}elseif($lijst->status == 3){
$status="normal user";
}elseif($lijst->status == 999){
$status=banned;
}
echo"
<option value='$lijst->status'>$status</option>
<option></option>
<option value='0'>Banned</option>
<option value='1'>Admin</option>
<option value='2'>Supporter</option>
<option value='3'>Normal User</option>
</select></td>
</tr>
<tr><td width='50%' height='24'>Username</td>
<td width='50%' height='24'><input type='text' name='username' value='$usn'></td></tr>
<tr><td width='50%' height='24'>Password</td>
<td width='50%' height='24'><input type='text' name='password' value='$lijst->password'></td></tr>
<tr><td width='50%' height='24'>Credits</td>
<td width='50%' height='24'><input type='text' name='credits' value='$lijst->credit'></td></tr>
<tr><td width='50%' height='24'>Email</td>
<td width='50%' height='24'><input type='text' name='email' value='$lijst->email'></td></tr>
<tr><td width='50%' height='24'>Full Name</td>
<td width='50%' height='24'><input type='text' name='fullname' value='$lijst->fullname'></td></tr>
<tr><td width='50%' height='24'>Messenger</td>
<td width='50%' height='24'><input type='text' name='messenger' value='$lijst->messenger'></td></tr>
<tr><td width='50%' height='24'>IP</td>
<td width='50%' height='24'><a href='iprun.php?ip=$lijst->ip' target='_blank'>$lijst->ip</a></td></tr>
<tr><td width='50%' height='24'>Host</td>
<td width='50%' height='24'>$lijst->host</td></tr>
<tr><td width='50%' height='24'>Reffered By</td>
<td width='50%' height='24'><input type='text' name='refferedby' value='$lijst->refferedby'></td></tr>
<tr><td width='50%' height='24'>Email</td>
<td width='50%' height='24'><a href='http://www.mafiaruler.com/admin/email.php?action=s&user=$lijst->username' target='_blank'>Click here to email user</a></td></tr>
<tr><td width='50%' height='24'>Confirm</td>
<td width='50%' height='24'><input type='submit' value='Save changes'></td>
</tr></table></form>";
Sql won't update
Codes:
(connecting to database is done in config.php wich is included (no database connect problems, everything works on other pages).
Code (part 1)
if ($_GET['a'] == 'update')
mysql_query("UPDATE users SET status='".$_POST['userstatus']."',username='".$_POST['username']."',password='".$_POST['password']."',credit='".$_POST['credits']."',email='".$_POST['email']."',fullname='".$_POST['fullname']."',messenger='".$_POST['messenger']."',refferedby='".$_POST['refferedby']."' WHERE id='".$_POST['idkey']."'");
echo $_POST['idkey'];
(i added echo $_POST['idkey'] to see if that was filled in, and it was, i got the right id !
Here the form code:
$usercheck = mysql_query('SELECT * FROM users WHERE username="'.$_POST['username'].'"');
$num_rows = mysql_num_rows($usercheck);
if($num_rows == 0){
echo '<font color=red><b>User not found ! <br> You searched for '.$_POST['username'].'</b></font><br>';
echo"<br><br><br>
<a href='user.php'>Try Again</a>";
}else{
$query = "SELECT * FROM users WHERE username='".$_POST['username']."'";
$uitvoer = mysql_query($query) or die (mysql_error());
while($lijst = mysql_fetch_object($uitvoer))
{
echo "<form action='".$_SERVER['PHP_SELF']."?a=update' method='POST'>
<font size='4'><b>Editing user info</b></font><font> (user '".$_POST['username']."')</font><br><br>
<table width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr><td width='50%' height='24'><u>User</u></td>
<td width='50%' height='24'></td></tr></table>
<br><table width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr><td width='50%' height='24'>Unique ID</td>
<td width='50%' height='24'>$lijst->id</td><input type='hidden' name='idkey' value='$lijst->id'></td></tr></tr>
<tr>
<td width='50%' height='24'>User status</td>
<td width='50%' height='24'><select size='1' name='userstatus'>";
$usn=$_POST['username'];
if($lijst->status == 0){
$status=banned;
}elseif($lijst->status == 1){
$status=admin;
}elseif($lijst->status == 2){
$status=supporter;
}elseif($lijst->status == 3){
$status="normal user";
}elseif($lijst->status == 999){
$status=banned;
}
echo"
<option value='$lijst->status'>$status</option>
<option></option>
<option value='0'>Banned</option>
<option value='1'>Admin</option>
<option value='2'>Supporter</option>
<option value='3'>Normal User</option>
</select></td>
</tr>
<tr><td width='50%' height='24'>Username</td>
<td width='50%' height='24'><input type='text' name='username' value='$usn'></td></tr>
<tr><td width='50%' height='24'>Password</td>
<td width='50%' height='24'><input type='text' name='password' value='$lijst->password'></td></tr>
<tr><td width='50%' height='24'>Credits</td>
<td width='50%' height='24'><input type='text' name='credits' value='$lijst->credit'></td></tr>
<tr><td width='50%' height='24'>Email</td>
<td width='50%' height='24'><input type='text' name='email' value='$lijst->email'></td></tr>
<tr><td width='50%' height='24'>Full Name</td>
<td width='50%' height='24'><input type='text' name='fullname' value='$lijst->fullname'></td></tr>
<tr><td width='50%' height='24'>Messenger</td>
<td width='50%' height='24'><input type='text' name='messenger' value='$lijst->messenger'></td></tr>
<tr><td width='50%' height='24'>IP</td>
<td width='50%' height='24'><a href='iprun.php?ip=$lijst->ip' target='_blank'>$lijst->ip</a></td></tr>
<tr><td width='50%' height='24'>Host</td>
<td width='50%' height='24'>$lijst->host</td></tr>
<tr><td width='50%' height='24'>Reffered By</td>
<td width='50%' height='24'><input type='text' name='refferedby' value='$lijst->refferedby'></td></tr>
<tr><td width='50%' height='24'>Email</td>
<td width='50%' height='24'><a href='http://www.mafiaruler.com/admin/email.php?action=s&user=$lijst->username' target='_blank'>Click here to email user</a></td></tr>
<tr><td width='50%' height='24'>Confirm</td>
<td width='50%' height='24'><input type='submit' value='Save changes'></td>
</tr></table></form>";