Reputation: 1537
I understand how to update active user data via using a form... But how to i update a certain column for the currently active user by click a button NO FORMS for example... i have a main page where a user can login via facebook, well when they login and accept permissions it then forwards them to the next step of my application, when they successfully authenticate all there information is stored onto my local mysql database in a users table. now they see the next page which consist of two buttons. Now what i want is if they click the "doctor" button it updates the column "job" to say doctor, and visa versa if they click "programmer" it updates the "job" column to programmer.
I'm trying to totally avoid letting them fill out information, I just want it to be a click this button append this to that field or click this button append that. If I'm not making any since, let me know and I will gladly explain in further details.
Upvotes: 2
Views: 2507
Reputation: 2670
Do you mean something like this?
Update
Your php file:
<?php
if($_POST['Doctor']){
$sql =("UPDATE users SET job='Doctor' WHERE userid='$someactiveuserid'");
$result = mysql_query($sql) or die(mysql_error());
} elseif($_POST['Programmer']){
$sql =("UPDATE users SET job='Programmer' WHERE userid='$someactiveuserid'");
$result = mysql_query($sql) or die(mysql_error());
}
?>
<html>
<body>
<form method="post" name="form1" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="submit" name="Programmer" value="Programmer"></br>
<input type="submit" name="Doctor" value="Doctor">
</form>
</body>
</html>
Hope this helps!
Upvotes: 2