First time PHPer looking for some help.
<?php
DEFINE ('DB_USER', 'hiddenforsecurity');
DEFINE ('DB_PSWD', 'hiddenforsecurity');
DEFINE ('DB_HOST', 'hiddenforsecurity');
DEFINE ('DB_NAME', 'hiddenforsecurity');
$email = $_POST['email'];
$password = $_POST['password'];
if($email && $password){
$dbcon = mysqli_connect(DB_HOST, DB_USER, DB_PSWD, DB_NAME) or die("cant connect");
$query = mysql_query("SELECT * FROM users WHERE email='$email'");
$numrows = mysql_num_rows($query);
if($numrows != 0){
echo "Account Located";
} else {
die("that user doesn't exist");
}
} else {
die("Please enter an email and a password.");
}
?>
Here is my HTML form:
<form method="POST" action="login.php">
<div class="form-group">
<label>Email address</label>
<input type="email" name="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
</div>
<div class="form-group">
<label>Password</label>
<input type="password" name="password" class="form-control password" id="exampleInputPassword1" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
When I press submit without anything in the inputs, I get the error specified in the PHP ("please enter an email and a password"). When I submit with test values for email and password that I manually placed in the DB, Chrome tells me that localhost is unable to handle this request, http error 500. I'm sure this is just a novice error and will be extremely grateful for any help. Thanks!
Other info: I am running the PHP on MAMP.