The Issue:
Undefined POST variables after form submission.
Research and Troubleshooting Done:
- Read over a multitude of questions here, almost all had to do with not having a name tag on the form field. All of my fields have a tag and ID present.
- Configured my PHP.ini to have $HTTP_RAW_POST_DATA set to -1
- Followed tutorials across PHP.net and W3SChools
At this point I'm lost. The data simply refuses to post, it all comes back undefined. Below is the HTML, PHP, and two screenshots showing the issue.
I am using PHPStorm's built in server on Windows.
signup.html
<div class="text-center col-md-4 col-md-offset-4">
<form id="user_signup" class="form-horizontal signInFields" action="../php/register.php" method="POST">
<input type="text" id="first_name" name="first_name" placeholder="First Name">
<input type="text" id="last_name" name="last_name" placeholder="Last Name">
<input type="email" id="user_email" name="user_email" placeholder="Email">
<input type="text" id="user_id" name="user_id" placeholder="User ID">
<input type="password" id="user_password" name="user_password" placeholder="Password">
<input type="password" id="confirm_password" name="confirm_password" placeholder="Confirm Password">
<button id="btn_signup" type="submit" name="signup_button">Sign Me Up!</button>
</form>
register.php
// Variables from the sign-up form POST action
$first_name = $_POST["first_name"];
$last_name = $_POST["last_name"];
$user_email = $_POST["user_email"];
$user_id = $_POST["user_id"];
$user_password = $_POST["user_password"];
$confirm_password = $_POST["confirm_password"];
// Add a new user to the database
$conn = new mysqli($servername, $username, $password);
$testQuery = mysql_insert($first_name,$last_name,$user_email,$user_id,$user_password);
if($conn->query($testQuery) === TRUE){
echo "New Record Created Successfully!";
} else {
echo "Error: " . $testQuery . "<br>" . $conn->error;
}
$conn->close();
At this point I'm baffled. As far as I can tell from W3Schools, PHP.net, and various questions here I've got it setup properly. However something is clearly off. Any and all help would be greatly appreciated.