Before anyone says this is a duplicate, I have checked and tried the solutions from this previously asked question. My question is different, I believe, because I don't have a separate php file - it's coded with tags in my HTML (so everything is in the same document).
Here is my PHP (database info left empty):
<?php
session_start();
$dbhost = '****';
$dbuser = '****';
$dbpass = '****';
$dbname = '****';
$connection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
$email=$_POST['email'];
$query="INSERT INTO tableName(email)
VALUES('$email')";
mysqli_free_result($result);
mysqli_close($connection);
?>
Here is my Materialize/HTML form:
<form action="/thankyou.php" method="POST">
<p class="input-header">Enter Your Email:</p>
<input id="email" type="email" name= "email" class="validate" required>
<br></br>
<input class="waves-light btn indigo lighten-2" type="submit">
<br></br>
<br></br>
<br></br>
</form>
Any ideas for why it's not working? I checked my MAMP phpmyadmin database and nothing is getting added. Please let me know if you have any suggestions! Thanks!