I am coding my first php app and I am basing it off a tutorial I was working on that worked. My code as of right now works fine until I get to the $var = $connection->query("INSERT INTO . . . etc.
At this point, the code immediately after the first $ just shows up as plaintext in firefox. (google shows the whole thing as text blah).
I will post my code here:
<?php
$dbServername = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbName = "cowboyserver";
$conn = mysqli_connect($dbServername, $dbUsername, $dbPassword);
mysqli_select_db($dbName, $conn);
$email = ($_POST['email']);
if(!$conn){
echo 'error';
}else{
$query = $conn->query("INSERT INTO email_list (email) VALUES ('$email')");
}
mysqli_query($query);
header("Location: ../index.html?signup=success");
echo '<p>email entered !! ! ! ! ! ! !! !! ! ! ! ! !</p>' ;
Additionally, here is the HTML : : : :
<form autocomplete="on" action="includes/signup.inc.php" method="POST">
<input type="email" name="email" placeholder="put your email here" class="blah"/>
</form>
EDIT: After trying some solutions, I have found that my php code breaks at a seemingly random point in the code. In the second answer posted, for example, the php code runs until it gets to "$conn->connect_error" in the if statement and then prints out everything after the -> instead of executing it.