This is my code, i have used almost the exact the same before and it worked. I have looked at the other answered questions without getting it to work.
The 'template.php' holds access to the sql database that has worked on all other pages. At the end is a image of the table
<?php
include_once('template.php');
if (isset($_POST['username']) and isset($_POST['password'])) {
$name = $mysqli->real_escape_string($_POST['username']);
$pwd = $mysqli->real_escape_string($_POST['password']);
$query = <<<END
INSERT INTO outlets(device_name,description,id_r)
VALUES('{$_POST['device_name']}','{$_POST['description']}','{$_POST['id_r']}')
END;
if ($mysqli->query($query) !== TRUE) {
die("Could not query database" . $mysqli->errno . " : " . $mysqli->error);
header('Location:index.php');
}
}
$content = <<<END
<form method="post" action="add_device.php">
<input type = "text" name="device_name" placeholder="Device Name"><br>
<input type="text" name="description" placeholder="Description"><br>
<select name="id_r">
<option value="1">Living Room</option>
<option value="2">Bedroom</option>
<option value="3">Kitchen</option>
<option value="4">Bathroom</option>
</select>
<input type="submit" value="Register">
<input type="Reset" value="reset">
</form>
END;
echo $content;
?>