Hi.
I'm new here, so i may be doing things the wrong way. If i am, please tell me, and i will change it.
I'll hurry to my problems.
I'm working on a project. A webpage with a log-in and a registration form. When you register as a user, you will be put in the database, and have a rank of "0". An admin will then have to accept you. Right now, my admin log-in works. The admin can even see the people who needs to be accepted, but when i push the submit button it errors me. Can anyone help? My code is:
<?php
include("navbar.php");
if ($admin<2) //altså er man en normal bruger
{
die ("Du har ikke rettigheder til at se denne side!");
}
else
if(isset($_POST['submit']))
{
$id = $_POST['id']; //this will return an array with user ids
foreach ($id)
{
$results = mysql_query("UPDATE users SET rank=1 WHERE id=$id");
}
}
{
$connect = mysql_connect("localhost","root","");
mysql_select_db("eksamen - phoenix");
$query = mysql_query("SELECT * FROM users WHERE rank='0'");
?>
<form action='admin.php' method='POST'>
<table>
<?php
while($row = mysql_fetch_assoc($query)) {
echo "
<tr>
<td>
".$row['username']."
</td>
<td>
".$row['email']."
</td>
<td>
".$row['real_name']."
</td>
<td>
<input type=\"checkbox\" name=".$row['id']." value=\"Godkend\">
</td>
</tr>
";} ?>
<tr>
<td>
<input type='submit' name='submit' value='Register'>
</td>
</tr>
</table>
</form>
<?php
}
?>
Next is another problem. I need a drop-down box, containing all the users with a rank of 1 or higher. Also, another drop-down box containing the numbers 1-3 should be displayed. After a click on the submit button, the selected user and the logged-in user, and the number should be put into the database. but, right now i can not get the drop-down box to show the usernames. What am i doing wrong here?
<html><body>
<?php include("navbar.php");
if(isset($_POST['submit1']))
{
$modstander = $_POST['id']; //this will return an array with user ids
echo "Hvem vandt kampen?";
echo "$modstander";
}
else
{
if ($_SESSION['username'])
{
$get = mysql_query("SELECT username FROM users WHERE rank>0");
Echo "Hvem spillede du imod?";
?>
<select name="modstander">
<?php
while($row = mysql_fetch_assoc($get))
{
$username=$row['username'];
echo"<option value=\".$username.\">$username</option>";
}
?>
</select>
<?php
echo "<input type='submit' name='submit1' value='Vælg'>";
}
}
?>
</html></body>