I have made a form but I can only insert data but not use a variable for example that will be included in the form when it is sent:
<?php
require_once 'database.php';
try{
$database_connection = database_connect();
} catch (PDOException $exc) {
echo $exc->getMessage();
exit();
}
$users = $database_connection->query('SELECT * FROM coffee')->fetchAll();
$title = 'Home';
$content = '
<h4>Title 1</h4>
<form method="POST">
<table>
<tr>
<td><input type="number" name="fname" required placeholder="First Name"></td>
</tr>
<tr>
<td><input type="text" name="lname" required placeholder="Last Name"></td>
</tr>
<tr>
<td><input type="text" name="age" required placeholder="Age" min="10" > </td>
</tr>
<tr>
<td><input type="submit" name="insert"></input></td>
</br>
</tr>
</form></table>
<br>
';
$content .= '<br><table>';
if(isset($_POST['insert']))
{
// get values form input text and number
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$age = $_POST['age'];
$uso = $database_connection->query('INSERT INTO coffee(id) VALUES(fname)');
}else{
echo "nothing";
}
foreach($users as $user) {
$content .= '<tr>';
$content .= '<td>' . $user["id"] . '</td>';
$content .= '<td>' . $user["type"] . '</td>';
$content .= '<td>' . $user["price"] . '</td>';
$content .= '<td><a href="index.php">' . $user["price"] . '<a/></td>';
$content .= '<td><a href="index.php">' . $user["price"] . '<a/></td>';
$content .= '</tr>';
}
$content .= '</table>';
include 'Template.php';
?>
Is it basically that I can not use: fname,: lname,: age some solution to this problem?