I've filtered out most of the html to cut the size down a bit.
<?
if ($accept) { //if the user hit the accept button (see form at the bottom)
//select needed data of user from table: "pending"
$query = "SELECT username, email FROM pending WHERE pid='$pid'";
$result = @mysql_query($query);
if (! $result) {
PrintTop();
print "Database Error: " . mysql_error();
PrintFoot();
exit();
}
$row = mysql_fetch_array($result);
$username = $row['username'];
$email = $row['email'];
//generate a random password, md5 it, and insert it into a new row in table: "profiles" along with username & email
srand((double)microtime()*1000000);
$password = substr(md5(rand(0,9999999)), 0, 8); #generates an 8 char long password (mix of nums and letters)
$encryptedpass = md5($password);
$query = "INSERT INTO profiles SET username='$username', password='$encryptedpass', email='$email'";
if (! @mysql_query($query)) {
PrintTop();
print "Database Error: " . mysql_error();
PrintFoot();
exit();
}
//finally, delete new user from the pending table
$query = "DELETE FROM pending WHERE pid ='$pid'";
if (! @mysql_query($query)) {
PrintTop();
print "Database Error: " . mysql_error();
PrintFoot();
exit();
}
//databases changes successfully, let user know he is accepted.
//write e-mail to user
$to = $email;
$subject = "Lore League Account: Accepted";
$message =
"Hello, $username.
There were no problems with your sign up application, so you are now a member.
------
Username: $username
Password: $password
------
You can change your password from the member index page. To log in, go to [url]www.lore-league.com/signup.php[/url] and enter the above user name and password (password is case sensitive). If you have any questions, feel free to e-mail [email]silvermoon@lore-league.com[/email].
Thankyou,
Silvermoon,
Webmaster/Admin of Lore-League.com
Guild Leader of Templum Purgationis
Co-Founder of the Lore League";
//send e-mail
mail($to,$subject,$message,$from);
//finally, print message to admin saying it was successful
PrintTop();
print "$username has been accepted as a member.<br>";
print "<a href=\"../memberindex.php\"><<Back</a>";
PrintFoot();
exit();
}
?>
//load of unrelated html here
//then the form starts
<form action="<?= $PHP_SELF ?>" method="POST">
<table width=600 bgcolor="#FFFFFF" align="center" cellspacing="1" cellpadding="2">
<tr>
<td bgcolor="#222222" width=290><div align="right"><font class="default">Name:</font></div></td>
<td bgcolor="#222222" width=290><div align="left"><font class="default"><?= $row['username'] ?></font></div></td>
</tr>
<tr>
<td bgcolor="#222222" width=290><div align="right"><font class="default">E-Mail Address:</font></div></td>
<td bgcolor="#222222" width=290><div align="left"><font class="default"><?= $row['email'] ?></font></div></td>
</tr>
<tr>
<td bgcolor="#222222" width=290><div align="right"><font class="default">Guild:</font></div></td>
<td bgcolor="#222222" width=290><div align="left"><font class="default"><?= $row['guild'] ?></font></div></td>
</tr>
<tr>
<td bgcolor="#222222" width=290><div align="right"><font class="default">IP Address:</font></div></td>
<td bgcolor="#222222" width=290><div align="left"><font class="default"><?= $row['ip'] ?></font></div></td>
</tr>
<tr>
<td bgcolor="#222222" width=290><div align="right"><font class="default">Sign-Up Date:</font></div></td>
<td bgcolor="#222222" width=290><div align="left"><font class="default"><?= $row['date'] ?></font></div></td>
</tr>
<tr>
<td bgcolor="#222222" width=290><div align="right"><font class="default">Other Information:</font></div></td>
<td bgcolor="#222222" width=290><div align="left"><font class="default"><?= $other ?></font></div></td>
</tr>
<? //print form allowing admin to accept or reject the user ?>
<tr>
<td bgcolor="#222222" width=290><div align="center"><input type="submit" value="Accept User" name="accept" class="mainoption"></div></td>
<td bgcolor="#222222" width=290><div align="center"><input type="submit" value="Reject User" name="reject" class="mainoption"></div></td>
</tr>
</table>
<input type="hidden" name="pid" value="<?= $id ?>"> //got a feeling the problem lies here.
</form>
Basically I've narrowed the problem down to the $id variable not being passed from the form, to the if ($accept) condition. I tried putting constants into the MySQL queries for pid= , and it worked fine.
So, is the following line:
<input type="hidden" name="pid" value="<?= $id ?>">
the problem causer? I can't think of anything else, but at the same time I don't see why this hidden field shouldn't pass on pid=$id...
Any help appreciated,