php - mysql UPDATE not changing table -
i have made form allow changing users "userlevel." however, cannot seem work. not changing userlevel after submit. php newbie. have tried researching past hour , cannot seem make progress here. simple missing. appreciated.
the form
<form action="dm/userupdate.php" method="post"> username: <input type="text" name="username" value="username"> <br> user level: <input type="number" name="userlevel" value="0"> <input type="submit" name="submit" value="change"> </form>
userupdate.php
<?php mysql_connect('localhost', 'username', 'password') or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); $userlevel = mysql_real_escape_string($_post["userlevel"]); $username = mysql_real_escape_string($_post["username"]); mysql_query($con,"update users set userlevel= $userlevel username ='$username'"); mysql_close($con); ?>
you should escape variables. or whatever called.
mysql_query("update users set userlevel= '".$userlevel."' username ='".$username."'");
notice used regular mysql no link required parameter. if new mysql advice learn mysqli right off bat since has handy improvements.
Comments
Post a Comment