How to detect button press and add it to mySQL database?

I was wondering if anyone can help me with this issue. I’m new and trying to make this work but failing to achieve it. can anyone please help me out. I have 4 machines and each of them have ON/OFF buttons. so what I want is that when I turn on/off the machine no’3 button it should show up on MySQL database showing which button was pressed and the machine. I’m using html, php and mySQL for this. I’m not sure what to add for php script. thanks


<form action="db.php">
<input class="buttonOne" type="submit" name="onButton" value="ON" />
<input class="buttonA "type="submit" name="offButton" value="OFF" />
<input class="buttonTwo" type="submit" name="onButton" value="ON" />
<input class="buttonB "type="submit" name="offButton" value="OFF" />
<input class="buttonThree" type="submit" name="onButton" value="ON" />
<input class="buttonC "type="submit" name="offButton" value="OFF" />
<input class="buttonFour" type="submit" name="onButton" value="ON" />
<input class="buttonD "type="submit" name="offButton" value="OFF" />


if (isset($_POST['onButton'])) {
    echo "On button was pressed.";
} else if (isset($_POST['offButton']){
    echo "Off button was pressed.";

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s