Well, I got that much of it working thanks to that last post.
I pass the username selected on to the next script which is a form to edit the information with.
In this form I pass several hidden fields containing the original value so that I can query the database and also check for what values were changed but for some reason the values in the hidden fields dont pass on to the next script when submitted.
A) Should I not be using hidden fields to do this, if not, what is the best alternative...
😎 If hidden fields should work what am I doing wrong...
Here is how I define the fields
<?php
$access_level = 5;
include 'accessctrl.php';
include 'header.php';
include 'db.php';
//Check to see if delete checkbox was checked
if (!isset($delete)){
//Pull information from database based on user chosen
$sql = mysql_query("SELECT * FROM members WHERE username='$member'");
while($row = mysql_fetch_array($sql)){
foreach($row AS $key=>$val){
$key = stripslashes($val);
}
//Set data to simple variables, 3 is used at end to not interfere with
//with the session variables
$first_name3 = $row['first_name'];
$last_name3 = $row['last_name'];
$username3 = $row['username'];
$email_address3 = $row['email_address'];
$user_level3 = $row['user_level'];
$tag3 = $row['tag'];
$info3 = $row['info'];
}
//If delete was checked
}elseif (isset($delete)){
//Delete row that includes that users information
$sql = mysql_query("DELETE FROM members WHERE username='$member' LIMIT 1");
//Check to see if that row still exists after deleted
$check = mysql_query("SELECT * FROM members WHERE username='$member'");
$dblcheck = mysql_num_rows($check);
//If its gone
if ($dblcheck == 0){
print "<br><br><font color=\"888888\"><b><center>";
print "$member Was Successfully Removed from the database!";
print "</b></font></center>";
//If its still there
} else {
print "<br><br><font color=\"888888\"><b><center>";
print "Unable to remove $member from database";
print "</b></font></center>";
}
//Exit Script without entering form
exit();
}
//Start form
?>
<html>
<head>
<title>Edit Member</title>
</head>
<body>
<br>
<br>
<center><font color="888888">Editing Username: <? echo $member; ?></font></center>
<form name="form1" method="POST" action="update_member.php">
<table width="50%" border="0" cellpadding="4" cellspacing="0" align="center">
<tr>
<td width="24%" align="left" valign="top">First Name</td>
<td width="76%"><input name="first_name2" type="text" id="first_name2" value="<? echo $first_name3; ?>"></td>
</tr>
<tr>
<td align="left" valign="top">Last Name</td>
<td><input name="last_name2" type="text" id="last_name2" value="<? echo $last_name3; ?>"></td>
</tr>
<tr>
<td align="left" valign="top">Email Address</td>
<td><input name="email_address2" type="text" id="email_address2" value="<? echo $email_address3; ?>"></td>
</tr>
<tr>
<td align="left" valign="top">Desired Username</td>
<td><input name="username2" type="text" id="username2" value="<? echo $username3; ?>"></td>
</tr>
<?
//Block User Level Assignment from Power User, but not Admin
if ($user_level = 5){
print "<tr>";
print "<td align=\"left\" valign=\"top\">User Access Level</td>";
print "<td><select name=\"user_level2\" value=\"$user_level3\">";
print "<option value=\"0\">Band";
print "<option value=\"1\">Writer";
print "<option value=\"2\">Artist";
print "<option value=\"3\">News Poster";
print "<option value=\"4\">Power User";
print "<option value=\"5\">Administrator</td>";
print "</tr>";
}
?>
<tr>
<td align="left" valign="top">Band/Artist Name</td>
<td><input name="tag2" type="text" id="tag2" value="<? echo $tag3; ?>"></td>
</tr>
<tr>
<td align="left" valign="top">Other Information/Notes:</td>
<td><textarea name="info2" id="info2"><? echo $info3; ?></textarea></td>
</tr>
<tr>
<td><input type="hidden" name="last_name3" id="last_name3" value="<? $last_name3 ?>">
<input type="hidden" name="username3" id="username3" value="<? $username3 ?>">
<input type="hidden" name="email_address3" id="email_address3" value="<? $email_address3 ?>">
<input type="hidden" name="first_name3" id="first_name3" value="<? $first_name3 ?>">
<input type="hidden" name="tag3" id="tag3" value="<? $tag3 ?>">
<input type="hidden" name="info3" id="info3" value="<? $info3 ?>">
<input type="hidden" name="user_level3" id="user_level3" value="<? $user_level3 ?>">
</td>
</tr>
<tr>
<td align="left" valign="top"> </td>
<td><input type="submit" name="Submit" value="Update"></td>
</tr>
</table>
</form>
<font color="888888">
<center>
All information will be changed AS SHOWN, if you accidentally degrade your
access level you will not be able to change it back!
</center>
</font>
</body>
</html>
I know this is a lot to look at, but I thought this would work, I cant really put the variables in a session because im already using sessions based on the user that is editing the data based on a DIFFERENT user then himself, so im a little confused as to where I should take this.
Just to clear the script up a bit...
$first_name and the other info variables with NO NUMBER are the session vars
$first_name2 and others are the data being submitted THROUGH the form
and
$first_name3 and others is the data pulled from the database based on the user chosen to edit, so the variables with 2 at the end are the edited values and 3 on the end are the original values.