MySQL update via Click of a image button PHP

Go To StackoverFlow.com

2

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.

2012-04-04 00:17
by Aaron Russell


2

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!

2012-04-04 00:51
by Alexander of Norway
Hey thanks, this looks to be exactly what im looking for except for some reasons its not doing anything when i click the image, i even turned it into a plain button and still nothing - Aaron Russell 2012-04-04 14:48
Maybe it would help if i posted the full pages code? Let me kno - Aaron Russell 2012-04-04 15:52
I have updated the cod - Alexander of Norway 2012-04-05 04:51