Okay so I fixed my mistake but I am still getting an error. I am not use to MySQLi but I would like to help my friend get something working for his site he is making.
<?php
if(isset($_POST['submit']))
{
$firstname = filter($_POST['firstname']);
$lastname = filter($_POST['lastname']);
$age = filter($_POST['age']);
}
$db = new MySQLi('localhost', 'root', '', 'register');
if ($db->connect_error) {
$message = $db->connect_error;
die($message);
}
$sql = 'SELECT * FROM users';
$result = $db->query($sql);
if ($db->error) {
$message = $db->error;
die($message);
}
$db->query("INSERT INTO users (firstname,lastname,age)
VALUES ('".$firstname."', '".$lastname."', '".$age."')");
mysqli_close($db);
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="confirmation.php" method="POST">
First Name:<br />
<input type="text" name="firstname" placeholder="First name" />
Last Name:<br />
<input type="text" name="lastname" />
Age:<br />
<input type="text" name="age" />
Submit:<br />
<input type="submit" name="submit" />
</form>
</body>
</html>
This is the error we are getting ->
( ! ) Notice: Undefined variable: firstname in C:\wamp\www\website\register.php on line 25
Call Stack
# Time Memory Function Location
1 0.0008 244952 {main}( ) ..\register.php:0
( ! ) Notice: Undefined variable: lastname in C:\wamp\www\website\register.php on line 25
Call Stack
# Time Memory Function Location
1 0.0008 244952 {main}( ) ..\register.php:0
( ! ) Notice: Undefined variable: age in C:\wamp\www\website\register.php on line 25
Call Stack
# Time Memory Function Location
1 0.0008 244952 {main}( ) ..\register.php:0
When I do this in the old MySQL I don't get no such error like this so I am very confused since it is working for me when I do it but with the SQLi I get the error.
filter()does?