I am trying to create a dynamic page and store it in a MySQL database. It connects to the database fine, but there seems to be an error in the SQL Syntax that I can't find. I've tried reformatting the code and cannot pin point it. Here's the PHP:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
$dbc = mysqli_connect('localhost', 'username', 'password', 'test_db')
or die("There was an error connecting to the database. Please try again later.");
$fullname = (string)$_POST['name'];
$guest_email = $_POST['email'];
$password = $_POST['password'];
echo "<h1>Thanks for your submission!</h1>";
echo "Your Name on File is: ". $fullname . '<br>';
echo "Your Email on File is: ". $guest_email . '<br>';
echo "Your Password on File is: ". $password . '<br>';
$add_query = "INSERT INTO test_form (full_name, email, user_pass) VALUES( $fullname, $guest_email, $password)";
$result = mysqli_query($dbc, $add_query)
or die("<strong>There was an error processing the form. Please call your IT support!</strong>". mysqli_error($dbc));
mysqli_close($dbc);
?>
</body>
</html>
And here's the HTML:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Test Form</title>
</head>
<body>
<h1>Test Form</h1>
<form action="index.php" method="post">
<input type="text" placeholder="Name" name="name"/>
<input type="email" name="email" id="email" placeholder="Email"/>
<input type="password" name="password" id="password" placeholder="Enter a password"/>
<input type="submit" value="Submit"/>
</form>
</body>
</html>