I see many old tutorials that do not use PDOs. I'm trying to insert but, I have not. The code is this:
<?php
require_once 'database.php';
$database_connection = database_connect();
$title = 'Home';
$content = '
<h4>Title 1</h4>
<table>
<tr>
<td><input type="text" 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="number" name="age" required placeholder="Age" min="10" > </td>
</tr>
<tr>
<td><input type="submit" name="insert"></input></td>
</tr>
';
$content .= '</table>';
// get values form input text and number
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$age = $_POST['age'];
// mysql query to insert data
$pdoQuery = "INSERT INTO 'users'('id', 'name', 'type') VALUES (:fname,:lname,:age)";
$pdoResult = $pdoConnect->prepare($pdoQuery);
$pdoExec = $pdoResult->execute(array(":fname"=>$fname,":lname"=>$lname,":age"=>$age));
// check if mysql insert query successful
if($pdoExec)
{
echo 'Data Inserted';
}else{
echo 'Data Not Inserted';
}
include 'Template.php';
?>
They give me errors of the following type:
Notice: Undefined index: lname in C: \ wamp \ www \ www \ tool.php on line 35
I'm a little disconcerted since I followed all the exact steps to get me wrong.