I can't understand why this will not be executed into the mySQL database? Everything is set and all it does is to update some values.
<?php
$con=mysqli_connect(This is filled.);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"UPDATE `members` SET `rank`='$_POST[rank]' WHERE `id`='$_POST[id]'");
mysqli_close($con);
header("Location: index.php");
?>
Heres the thing that should fill the $_POSTs
<form action="setrank.php" method="post">
User:
<select>
<?php
$result = mysqli_query($con,"SELECT * FROM members ORDER BY id");
while($row = mysqli_fetch_array($result))
{
echo "<option name='id' id='id' value='" . $row['id'] . "'>" . $row['username'] . " (" . $row['id'] . ")</option>";
}
?>
</select><br />
Set rank to:
<select><option name="rank" id="rank" value="0" >Guest.</option><option name="rank" id="rank" value="1" >Moderator.</option><option value="2" name="rank" id="rank">Administrator.</option><option value="3" name="rank" id="rank">Owner.</option></select>
<br /><input type="submit">
</form>
Thank you very much for help, i've been using hours. :/
nameattribute belongs on<select name='rank'>not on<option name='rank'>, same foridYou should be checking that the form was posted before attempting to do theUPDATE, and most importantly, the code is vulnerable to SQL injection. It is important to start learning how to usemysqli::prepare()to create prepared statements, safe from SQL injection.