I'm trying to setup a basic web page that allows the user to add a row in a mysql table in a database for the purpose of turning an LED light on and of with the use of an arduino. However when I try to submit the form, the page returns a 500 status and the mysql query isn't executed. I'm running a linux-apache-mysql-php server on my computer. Why would this be?
<!doctype html>
<html>
<head>
<title> ARDUINO CONTROL CENTER </title>
<meta charset = "utf-8"/>
<link rel = "stylesheet" type = "text/css" href = "#" />
</head>
<body>
<h1> Welcome to the online arduino controller </h1>
<p> From here you can actually control an arduino in my room that will turn an LED light on and off. </p>
<form method = "get" action = "index.php">
<select name = "action">
<option value = "ON">ON</option>
<option value = "OFF">OFF</option>
</select>
<input type = "number" name = "duration"/>
<input type = "submit" />
</form>
</body>
</html>
<?php
$host = 'localhost';
$username = 'petros';
$password = '**********'; //can't give my password
$dbc = mysql_connect($host,$username,$password) or die("Unable to connect to server");
$db = 'ledrequests';
$sdb = mysql_select_db($db,$dbc) or die("Unable to connect to database.");
if(isset($_GET['action']) && isset($_GET['duration'])){
$action = $_GET['action'];
$duration = $_GET['duration'];
$query = "INSERT INTO requests(`act`,`duration`) VALUES ('$action',$duration)";
mysql_query($query);
}
?>