Html GET submission form instead of POST on submit form

Sorry my network skills, but I have a very rudimentary problem.

I have this html form that ideally should have called my / login url with a message, but for some reason it always sends a request to get this URL and fails. I can’t understand how this happens.

This is my html form

<!DOCTYPE html> <html class="no-js"> <head> <title>Login - MobileMedic</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="description" content=""> <meta name="author" content="" /> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,800italic,400,600,800" type="text/css"> <link rel="stylesheet" href="./css/font-awesome.min.css" type="text/css" /> <link rel="stylesheet" href="./css/bootstrap.min.css" type="text/css" /> <link rel="stylesheet" href="./css/jquery-ui-1.9.2.custom.min.css" type="text/css" /> <link rel="stylesheet" href="./css/App.css" type="text/css" /> <link rel="stylesheet" href="./css/Login.css" type="text/css" /> <link rel="stylesheet" href="./css/custom.css" type="text/css" /> <script src="./js/jquery-1.9.1.min.js"></script> <script src="./js/alert.js"></script> <script src="./js/jquery-ui-1.9.2.custom.min.js"></script> <script src="./js/bootstrap.min.js"></script> <script src="./js/plugins/parsley/parsley.js"></script> </head> <body> <div class="gifload"></div> <div id="login-container"> <div id="logo"> <a href="./index.html"> <img src="./images/logos/logo-login.png" alt="Logo" /> </a> </div> <div id="login"> <h3>Welcome to Apprick Technologies.</h3> <h5>Please sign in to get access.</h5> <form method="post" action="/login" id="login-form" class="form parsley-form" data-validate="parsley"> <div class="form-group"> <input type="email" class="form-control" id="email" placeholder="Email" required="required"> </div> <div class="form-group"> <input type="password" class="form-control" id="password" placeholder="Password" required="required"> </div> <div class="form-group"> <input type="submit" class="btn btn-primary btn-block" name= "Signin" value="Signin"/> </div> </form> </div> </div> <!-- /#login-container --> </body> 

To make the question more clear, I use express js from parse.com, and here are two specific routings

 app.get('/login', function(req, res) { res.send('get is called'); }); app.post('/login', function(req, res) { res.send('post is called'); }); 

Now, no matter what I provide in my form method, I always get "get called" in the browser when I submit the button.

I also tried to debug what happens in the developer console, and this is what I get

enter image description here

0
source share
1 answer

I tried your code and it works like a "POST" request. Try changing your request to "GET" and you may notice in the URL that it has something like this at the end of "? Signin = Signin" .

Include the "name" attribute in the input tags.

Example:

 <input type="email" name="email" class="form-control" id="email" placeholder="Email" required="required"> 

And you can see something like this when submitting the form:

 /login?email=testemail%40test.test&Signin=Signin 
0
source

All Articles