I am trying to fill up a form that has following fields :
old password , new password , verify password
<b><u>Please Enter the Informations</u></b><br>
<form method=post action="chpass.php?action=changepass">
<table border=0>
<tr><td>LAN UserName</td><td></td></tr>
<tr><td>Old password</td><td><input type="password" name="password"></td></tr>
<tr><td>New password</td><td><input type="password" name="password1"></td></tr>
<tr><td>Conform password</td><td><input type="password" name="password2"></td></tr>
tr><td colspan=2 align=center>
<input type=submit name="submit" value="submit">
<form><input type="button" onClick="show();" value="Logout"></form>
Using following piece of code in python:
br.open('url_of_form')
br.select_form(nr=0)
br['password']='abc'
br['password1']='bcdef'
br['password2']='bcdef'
br.submit()
I have used this piece of code before to login to site but this isn't working while trying to change password . The error message says 'ParseError: nested FORMs' .
what am i doing wrong ?
You have two open tags and one close tag "form". Maybe its a problem? Try to use grab
Related
I can't get an input field in a form to send a value to the server. (I'm using flask + python on Google App Engine).
Please excuse me if this is a rookie question...
Part of my html template file:
<form class="form-inline" action="/rm_list" method="POST">
<div class="row" >
<div class="col-span-6">
<fieldset>
<input class="form-control form-control-lg" type="text" name="searchtext" placeholder="Product...">
<input name="text1">
<button class="btn btn-primary" type="submit"><i class="material-icons w3-text-black" >search</i></button>
</div>
...
...
some radio buttons
So I dumped the POST data to the terminal to debug:
my_data = request.form
for key in my_data:
print ('form key '+key+" "+my_data[key])
After trying different solutions, I found that the culprit is the type="text" attribute.
I could see the value of the simple text1 input, but the value from the searchtext input just wasn't in the received data :-(
If I remove "type="text" as follows:
<input class="form-control form-control-lg" name="searchtext" Placeholder="Product...">
then the searchtext field is received Ok by the server.
Any ideas what I'm doing wrong?
Thanks!
It seems to me that your field is simply missing the value attribute. – Anonymous
I'm working with django and I want to calculate something depending on what the user put on the selectboxes of my page, but I don't know how to connect that with my python code that calculates everything, please help :(
You can use a html form element like this with method post and action="path_of_your_python_file"
<form name="search" action="calculate.py" method="GET">
Search: <input type="checkbox" name="user_input">
<input type="submit" value="Submit">
</form>
Then in calculate.py
import cgi
form = cgi.FieldStorage()
searchterm = form.getvalue('user_input')
// Do your calculation here
I think that will help
Trying to build my own webmail client.
I get a template for the web part which look like this
<form name="input" action="test2.py" methog="get" class="form">
<input type="text" name="Username" placeholder="Username">
<input type="password" name="Pass" placeholder="Password">
<button type="submit" id="login-button">Login</button>
</form>
Would like to get the input on click on the button of Username && Pass via GET method to fill this bunch of code in python.
user = ???(Username)
pass = ???(Pass)
And print to a new empty html file the value of thoses var.
New to python so everything I try seem to fail.
You should use method="post", it won't work with a GET method (however it is misspelled, you wrote "methog").
Write import request without quotes at the top of your python file.
Now use request.inputForm['name'] without quotes to access form elements where name is the element name.
I want to fill out this form using Python:
<form method="post" enctype="multipart/form-data" id="uploadimage">
<input type="file" name="image" id="image" />
<input type="submit" name="button" id="button" value="Upload File" class="inputbuttons" />
<input name="newimage" type="hidden" id="image" value="1" />
<input name="path" type="hidden" id="imagepath" value="/var/www/httpdocs/images/" />
</form>
As you can see, there are two Parameters that are named exactly the same, so when I'm using Mechanize to do it, what would look like this:
import mechanize
br = mechanize.Browser()
br.open('www.site.tld/upload.php')
br.select_form(nr=0)
br.form['image'] = '/home/user/Desktop/image.jpg'
br.submit()
I am getting the Error:
mechanize._form.AmbiguityError: more than one control matching name 'image'
Every solution I found in the Internet (including this site) didn't work. Is there a different approach?
Renaming the input in the HTML form is sadly not an option.
Thanks in Advance.
You should use find_control instead; you can add a nr keyword to select a specific control if there is ambiguity. In your case, the name and type keywords should do.
Also note that a file control doesn't take a value; use add_file instead and pass in an open file object:
br.form.find_control(name='image', type='file').add_file(
open('/home/user/Desktop/image.jpg', 'rb'), 'image/jpg', 'image.jpg')
See the documentation on forms in mechanize.
I am trying to make a user registration and login for an application I'm working on using the form below.
<html><form method="get" action="login">
Email Address: <input name="email" type="text"><br/>
Password: <input name="password" type="password"><br/>
<input type="submit" value="Submit" />
</form>
</html>
However the user name and password show up in the url, as does the submit button.
http://localhost:8080/login?email=123&password=123&submit=Submit
How do I stop this happening?
They show up in the URL because your form is using the GET method, you should be using POST and processing the values on the server side.
In addition to the POST/GET confusion Shawn points out, you might be interested to look at Cherrypy's built-in authentication tool.