I am trying to set up a form for a user to enter information and then for that information to be inserted into a SQL table. I am not getting any error messages but the table is not updating in my database.
My form page is this:
<!DOCTYPE html>
<html>
<head>
<title>Input 2</title>
</head>
<body>
<h1>Add a user</h1>
<form action="input-followup2.php" method="post">
First Name:
<br/>
<input type="text" name="firstName">
<br/>
<br>
Last Name:
<br/>
<input type="text" name="lastName">
<br/>
<br>
Email Address:
<br/>
<input type="text" name="emailAddress">
<br/>
<br>
Monthy Food Budget:
<br/>
<input type="number" step="0.01" name="foodBudget">
<br/>
<br>
Monthly Utility Budget:
<br/>
<input type="number" step="0.01" name="utilityBudget">
<br/>
<br>
Monthly Entertainment Budget:
<br/>
<input type="number" step="0.01" name="entertainmentBudget">
<br/>
<br>
<input name="Add User" type="submit" value="Submit">
</form>
</body>
The action for the form summit button links to this page:
Your input was received as:
<?php
$firstName = $_REQUEST["firstName"];
$lastName = $_REQUEST["lastName"];
$emailAddress = $_REQUEST["emailAddress"];
$foodBudget = $_REQUEST["foodBudget"];
$utilityBudget = $_REQUEST["utilityBudget"];
$entertainmentBudget = $_REQUEST["entertainmentBudget"];
echo '<br/>';
echo '<br/> Name: ';
echo $firstName;
echo ' ';
echo $lastName;
echo '<br/> Email Address: ';
echo $emailAddress;
echo '<br/> Food Budget: $';
echo $foodBudget;
echo '<br/> Utility Budget: $';
echo $utilityBudget;
echo '<br/> Entertainment Budget: $';
echo $entertainmentBudget;
?>
<?php
require_once 'login.php';
$connection = mysqli_connect(
$db_hostname, $db_username,
$db_password, $db_database);
if(mysqli_connect_error()){
die("Database Connection Failed: " .
mysqli_connect_error() .
" (" . mysqli_connect_errno() . ")"
); };
$addUser = "INSERT INTO CUSTOMER (CustomerID, CustomerFirstName, CustomerLastName, CustomerEmail,FoodBudget, UtilityBudget, EntertainmentBudget)
VALUES (001,{$connection ->real_escape_string($_POST[firstName])}, {$connection ->real_escape_string($_POST[lastName])},{$connection - >real_escape_string($_POST[emailAddress])}, {$connection ->real_escape_string($_POST[foodBudget])}, {$connection ->real_escape_string($_POST[utilityBudget])}, {$connection ->real_escape_string($_POST[entertainmentBudget])} );";
$upload = mysqli_query($connection, $addUser);
mysqli_close($connection);
?>
When I run the action, and check SELECT * FROM CUSTOMERS;
the fields continue to return null
. Can someone point me in the right direction?