How to make an input validation for an 'add button'. and I need to use the $_POST data and function is_numeric and must put up the following message: "Data must be numeric", Also if username section is left blank, a message "Username is required" needs to be shown. the form has username, age and amount. (sorry, I just started learning php, don't really know how to code.. please help!) Many thanks!
This is what i got so far
if (isset($_POST['add'])) {
echo "age,amount " . $_POST['age and amount must be numeric'];
echo "age " . $_POST['age is required'] ;}
The database using an INSERT statement.
$stmt = $pdo->prepare('INSERT INTO autos
(age, amount) VALUES ( :age, :amount)');
$stmt->execute(array(
':age' => $_POST['age'],
':amount' => $_POST['amount']));