-1

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.

chaserobbins
  • 17
  • 1
  • 6
  • 500 internal server error is a generalize error, it might be happened to a number of reasons . Please enable php display error on to know actually error. Check this . post https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display – Samir Das Jan 14 '18 at 05:31

1 Answers1

0

You mixed up mysqli and mysql function so that can caused the 500 error

개발팡야
  • 163
  • 6