0

I'm trying to implement a basic login function in PHP on a website I'm making. I can't seem to make this form submit in any way, however.

There are some bootstrap styles but that shouldn't impede anything.

I have also not included much of the surrounding html code, and any includes.

<?php 
      $fname  = basename($_SERVER['PHP_SELF']);
      echo $_POST["email"];
 ?>

<html>
<body>
<div class = 'card-body bg-dark container'>
    <form class = 'form-group' action = "<?php echo $fname; ?>" method = "post">
      <input type = 'email' class = 'form-control' placeholder = 'Example@website.com' name = "email"><br/>
      <input type = 'text' class = 'form-control' placeholder = 'Password' name = 'password'>
      <br/>
      <input type = "button" class = 'btn btn-block text-light dark-theme' value = "Forgot Password?">
      <input type = "button" class = 'btn btn-block text-light dark-theme' value = "Login" name = "submit">
      <input type = "button" class = 'btn btn-block text-light dark-theme' value = "Report an Issue">
    </form>
  </div>
  </body>
  </div>

I've looked at many examples but I can't make this work in my own code. Any help is appreciated!

1 Answers1

1

You have no button with the type "submit".

Try to change this element :

<input type="submit" class="btn btn-block text-light dark-theme" value="Login" name="submit"> 

A type button does not trigger the form to be submitted.

Also, as pointed by Funk Forty Niner, you have a "undefined index" notice thrown on this line :

echo $_POST["email"];

And should be :

if (isset($_POST["email")) {
    echo $_POST["email"];
}

Have a look to : How do I get PHP errors to display?

Syscall
  • 16,959
  • 9
  • 22
  • 41