Debug a Http 405 "Method Not Allowed" - html

A web server is running (on EC2) and I'm testing this simple Html5 login form with a method="post" attribute in two ways:
as-is
within a larger website
<div>
<form action="" method="post" >
<p/>
<input id="username" type="text" name="username" placeholder="Username" >
<p/>
<input id="password" type="password" name="password" placeholder="Password" >
<p/>
<input type="submit" class="btn" value="Login">
</form>
</div>
A handler in the Python-based web server includes:
username = self.get_argument('username')
password = self.get_argument('password')
The first method works with a Http 200 but the second generates a Http 405 "Method Not Allowed". Both use the identical handler code on the web server.
I cannot find where the problem is. What is the best way to debug this?

The problem was with the web-server and the order of the parameters/attributes for the Class function handling the Post method.

Related

HTML E-mail form

So my site is almost done but I'm stuck on the part of sending an email.
Everything works, when I fill in the fields. But it always gets saved as a draft so I don't receive the email.
Here is my html code:
This code is copied from a site.
<form action="mailto:myemailadress#gmail.com" method="post" enctype="text/plain">
Name:<br>
<input type="text" name="name"><br>
E-mail:<br>
<input type="text" name="mail"><br>
Comment:<br>
<input type="text" name="comment" size="50"><br><br>
<input type="submit" value="Send">
<input type="reset" value="Reset">
</form>
action="mailto:myemailadress#gmail.com" <-- This is not correct.
You'll have to point your post submission to a handler php file that will process the form request and submit the email.
Now, some host providers do have a php mailer to make us things easier, e.g godaddy https://www.godaddy.com/es/help/using-our-php-form-mailers-on-web-and-classic-hosting-8376 .
An example of php mail handler for forms can be found here http://www.freecontactform.com/email_form.php . It has some validation code too.
There is a possibility that you're using a server that doesn't support PHP but ASP, .NET, Node.js or some other, in that case i can't help you because i'm not familiar to none of them :)

Error: 405 When accessing HTML page after Form submission

I am trying to post a dimple FORM in HTML as mentioned below:
<form name="myform" method="post" action="Home.html" onsubmit="return validateform()" >
<label class="labelText">
Name: </label>
<input class="textBoxName" type="text" name="name"><br/>
<label class="labelTextPassword"> <br/>
Password:</label>
<input type="password" name="password"><br/>
<input class="loginButton" type="submit" value="Login">
</form>
Its working successfully on my SYSTEM. but when I hosted my site on Azure, after validating name and password its not re-directing to "Home" Page. It shows error
as:
The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used. (Error: 405)
Can please anyone have any idea about this issue?
405 means Method not allowed.
It means that Home.html cannot accept a POST request
So try using the get method while sending the data and it would work.

How to include recieved token into a url wordpress

Ive made this very simple form:
<form action="http://xxxxxx.xxx/GetLoginToken.ashx?userName=USERNAME&password=PASSWORD" method="get" name="HentToken" target="_blank">
Username:<input name="USERNAME" type="text" />Password: <input name="PASSWORD" type="text" /><input type="submit" value="Submit" /></form>
It then returns a "token", or 20 digits, to my browser, and writes it in the browser.
Is there any way I can make it so that the token is included in a URL, and then open that URL instead of just writing the token to the browser window?
http://xxxx.xxx/Open.ashx?token=[TOKEN]
I'm not a programmer and I know this one is all to simple, but I'm totally lost.

Username and password appearing in the URL

In my rails app, I have a login page like this:
<body>
<form action="/my_app/homepage" method="get" class="navbar-form pull-left">
<input name="username" type="text" class="span2">
<input name="password" type="password" class="span2">
<button type="submit" class="btn">Submit</button>
</form>
</body>
When I click on the Submit button it takes me to the /my_app/homepage but at the same time it also displays the username and password in the addressbar.
Am I doing it the wrong way? How can I avoid displaying the username & password?
That is because the Http Request method of FORM is GET. Which would always show the form data in the URL. To hide the data of the form, you need to use POST request.
Change the code to the following:
<form action="/my_app/homepage" method="post" class="navbar-form pull-left">
<input name="username" type="text" class="span2">
<input name="password" type="password" class="span2">
<button type="submit" class="btn">Submit</button>
</form>
Check the method="post" and you'll get the URL only without any sort of Query String.
The GET method will append the form variables to the URL, using the POST method. From W3Schools:
"POST is a little safer than GET because the parameters are not stored in browser history or in web server logs." Also "Data is not displayed in the URL".
http://www.w3schools.com/tags/ref_httpmethods.asp

Passing form variables through URL

What I want to accomplish is logging in to a website by simply typing in the form variables in the URL.
HTML code:
<form action="httpclient.html" onsubmit="return checkSubmit();" method="post" target="_parent" name="frmHTTPClientLogin">
<input type="hidden" name="mode" value="191">
<label>Username</label>
<input border="1" style="width:150px" maxlength="60" name="username">
<label>Password</label></pre>
<input type="password" border="1" style="width:150px" autocomplete="off" name="password" maxlength="60">
This is the relevant past of the code. Now I want to login to this site http://10.100.56.55/httpclient.html just by passing values typed in the url. Firstly is it possible. If yes then what exactly do i need to type for userame :name and password being pass ?
and what encoded URL will be passed in POST method if any?
Change method="post" to method="get"
If you want to type the Querystring in for the username and password, you need to do this in the address field of your browser:
http://10.100.56.55/?username=name&password=pass
EDIT:
You need to find out where the form is going and what it's doing. For this, you need to check what the submit javascript function called 'checkSubmit()' is doing. You can do this by opening the page in your browser and doing a view source. If the javascript is external to the html file, check the js links on the page and open those up to find that function. The function might have the querystring parameters you're looking for.
<input type="text" class="form-control" placeholder="Products" name="search" value="search" id="search">
<input type="text" class="form-control" placeholder="Products" name="search" value="search" id="search2">
<button type="submit" class="btn btn-default" onclick="location.href='\search.php?search='+ document.getElementById('search').value+'&search2='+document.getElementById('search2').value;"> Search</button>
the issue was in the input tag <input type="hidden" name="min_price" value="200"> forward slash was missing,I have added the forward slash and it works now <input type="hidden" name="min_price" value="200"/>.
It's not possible to do that; the form would have to use the GET method.