Since you haven't provided your HTML form to go with your PHP, am submitting the following.
If your HTML form does not contain the following or similar, including form elements with name attributes for each and no typos, then there should not be any reason for failure.
Nota: name="Username"
and name="username"
are two different animals altogether.
<form action="handler.php" method="post">
Username:
<input type="text" name="Username"><br>
Password:
<input type="password" name="Password"><br>
Email:
<input type="text" name="Email"><br>
<input type="submit" name="submit" value="Submit">
</form>
Plus, as stated in comments, you're best using the form's actual method. Forms default to GET if omitted, therefore when using a POST method, it should be explicitly included in it.
Important sidenote:
Using GET to send information over the Internet, isn't safe; especially for passwords.
To debug, use error reporting.
Add error reporting to the top of your file(s) which will help find errors.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// rest of your code
Sidenote: Error reporting should only be done in staging, and never production.
References:
"Is there a better way of checking if the value is provided?"
Using a conditional empty()
is fine, which is what you're doing right now.
You can tack on a conditional isset()
also, but not required; see the link below about it.
$Username = $_POST['Username'];
$EnteredPassword = $_POST['Password'];
$Email = $_POST['Email'];
if (!empty($Email)) //Checks for email necessary for sign up
{
// Perform Sign Up Stuff
}
else
{
// Perform Login Stuff
}
or:
if (!empty($_POST['Email']))
{
// Perform Sign Up Stuff
}
else
{
// Perform Login Stuff
}