Jacques Mathieu
Jacques Mathieu

Reputation: 113

Html form method post not working correctly on localhost

I recently installed sails.js to act as a web server to host all of my html and other files, and have come across a problem in my login form. When the html form method is set to post, I come across a 404 error, claiming it can't find the file. However, when I change the method to a get method, it loads the appropriate html file without problem (but displays the username and password in the url, yikes!). Even stranger, when I type the file path (that the post method outputs) in a separate tab, the page is loads without any problems.

The project I am working on is a learning project, so that I can learn the inner workings of a web page, using js, jquery, angularjs, css, html and so on. All I want to do is have the login form to redirect me to the 'logged in' page where all it says is 'Login Successful'. I do not have a list of registered users or anything of that type, I just want it to go to the next page! Here is the code ;)

<form name="login" method="post" accept-charset="utf-8" action="../html/KLASSY_LOGGED_IN.html">
    <div class="line">
        <label for="username">Username</label>
        <input type="username" name="myUsername" id="username" pattern=".{6,}" placeholder="" ng-required="true">
    </div>
    <div class="line">
        <label for="password">Password</label>
        <input type="password" name="myPassword" id="pwd" pattern=".{8,}" placeholder="" ng-required="true">
    </div>
    <div class="line submit">
        <input type="submit" id="cusLogin" value="Login" />
    </div>
</form>

Each file that I reference using '../' works fine. In the link href attribute and the script src attribute, this type of file reference works fine. There is NO server code. All I want it to do is to take me to the 'logged in' page without any server code. This worked fine outside of sails.js, but why not inside of sails.js?

Upvotes: 3

Views: 2084

Answers (1)

Zach Leighton
Zach Leighton

Reputation: 1941

You need to have a handler be some type of script you can't just point the action to this page.

../html/KLASSY_LOGGED_IN.html

What you could do is have the action be javascript which redirects you to that page.

Upvotes: 1

Related Questions