I have already build a functioning login page which redirects the user the index.php file. From previous help, I was able to get the wage and display it on the page depending on which user logs in. This is the table users in the database user_registration
user_id username password email wage
1 johnsmith jsmith99 jsmith@gmail.com 100
2 davidscott dscott95 davidscott@gmail.com 90
The part i am stuck on is creating a functioning form that the user can update their wage to the sql database.
Can someone please help me with the php code? This is the form i already have in place:
<form id="change-wage" action="update.php" method="post">
<input type="text" id="new_wage" name="new_wage">
<input type="button" value="Save">
</form>
EDIT: this is the code, The aim of it is that the user can update the wage value in the table by filling in the textbox and pressing submit. any Ideas how i can acieve this?>
<?php //CHANGING THE WAGE
$username = '$_SESSION['MM_Username'];';
if (isset($_POST['submit'])){
$wage = $_POST['wage-new'];
//connect to server
mysql_connect ("localhost","root","") or die ("Could not connect");
mysql_select_db("user_registration") or die ("Could not connect to the database");
mysql_query ("UPDATE users SET wage='$wage' WHERE username = '$username'") or die ("Could not update");
}
?>