I am running a web server by Flask. I need python flask code to trigger submit button to be clicked on the HTML page. Then the page can "POST" data to the server. In the entire process, I should not click any buttons on the HTML page. Only thing I can do is to start the server at the very beginning. Does anyone know how to do that?
Thanks.
I know how to "POST" data from client-side. I only need to allow the server-side to trigger button at the beginning. I looked up the "RESPONSE" but can not figure out.
HTML:
<form action="" method="POST">
<label> Username </label>
<input type="text" id="trans" name="username" value={{request.form.username}}>
<button type=”submit”> Submit </button>
</form>
I currently have a web contain a recorder. I will play sound on my server and use iPhone and android phone to access the web to test the difference voice quality between devices. I need the server to trigger the button at the very beginning on multiple clients so they can start to record at the same time.
On the Flask server you need to have a function that receives the form once the submit button is clicked.
from flask import Flask
from flask import request
app = Flask(__name__)
#app.route('/handle_form>', methods = ['GET', 'POST', 'DELETE'])
def handle_form:
In the html you need to make sure the action of the form points to the url of /handle_form of the website :
<form action="{{ url_for('handle_form') }}" method="POST">
<label> Username </label>
<input type="text" id="trans" name="username">
<button type=”submit”> Submit </button>
</form>
The value of the input username cannot be obtained from the server before this form is submitted. I do not understand why you are trying to access the value of this form from server before submitting it.
Related
I want to create a section of my portfolio website where people can contact me. It's designed to look similar to an email. I don't want to just include a link, but a whole form so they don't need to open a new window to send me an email. They can enter their name, email address, topic, and content then hit a send button.
The design is based off this website:
email form from The Craftsmen
The Craftsmen
I'm using Nextjs for this project and I image the code will look something like this:
<section id='contact'>
<div >
<form action="" >
<div>
<div >
<input type="text" placeholder="Name"/>
<input type="email" placeholder='E-mail'/>
<input type="text" placeholder='Subject'/>
<input type="text" placeholder='Message'/>
</div>
<div >
<button type="submit">Send</button>
</div>
</div>
</form>
</div>
</section>
Is there any way to make these input values into an email that is sent automatically to me? No need to open their email in browser.
You would need to have a page on your web server that would accept this submission and then process the information. Sending the email from the backend.
The only way to do it client side is to have a mailto: link and this would open the clients email client in a new window.
I mean you could potentially try sending through Gmail on the client side, but you may end up in a place where your username and password, to login to Gmail and send, are served with your JavaScript code. Then you have an issue larger than not being able to send email from the client side.
Let's say I have a website where there is a button. When you click on this button the website will send the current page html (either as the body of an email or as an attachment ex: index.html) to a specific email address. Is this possible? If so, how? (I want to do it in either with html tags or javascript).
It's like sending a form but instead you send an html page.
What you're describing looks to be a use case for NodeMailer. Assumption here is that you're using Node.js as your backend. There are many options for other languages pypi-mailer being a common option for python.
Regardless, you would need to have a html form (or a default option of email)
<form action="/sendMail">
<label for="email">Email: </label><br>
<input type="text" id="email" name="email" value="Enter your email"><br>
<input type="submit" value="Submit">
</form>
<p>If you click the "Submit" button, the form-data will be send to an endpoint /sendMail".</p>
Then you would need Javascript on the front-end to actually get the object. I believe this answer is what you're looking for here.
This link explains how to actually use nodemailer to send an email.
Hope this helps!
I'm messing with testing XSS using a simple html form that redirects to an insecure page with a login form (PHP server side). I'm trying to get an alert to popup on the page with the login information of the user once they hit the 'login' button. However, even after something simple like this on this initial page the redirects:
<body onload="document.forms[0].submit()">
<form action="localhost:8000/testpage.php" onsubmit="" method="POST">
<input type="hidden" name="test" value="><script>alert(1)</script>">
</form>
</body>
I cannot get anything to appear successfully.
I would like to write a program that would log in to my school's website and check for updates that i should be made aware of. I am relatively new to JavaScript. I looked at the source code for the login page and it appears that the username and password is sent using the action attribute. (I tried to find a JavaScript function that is called when the button is pressed , but failed. Also the action attribute is set to a value. ) I Theorize that if i have my login credentials, then if i know the format of the data being sent to the server for verification, i can write a c program that mimics the operation of the login page. How to i see what is being sent ?
Here is the websites code:
<form action="http://[myschoolsdomainname].edu/login/index.php" method="post" id="login">
<div class="loginform">
<div class="form-label"><label for="username">Username</label></div>
<div class="form-input">
<input name="username" id="username" size="15" value="815008955" type="text">
</div>
<div class="clearer"><!-- --></div>
<div class="form-label"><label for="password">Password</label></div>
<div class="form-input">
<input name="password" id="password" size="15" value="" type="password">
<input value="Login" type="submit">
<input name="testcookies" value="1" type="hidden">
</div>
<div class="clearer"><!-- --></div>
</div>
</form>
N.B. I am not trying to do anything malicious, i simply want to periodically check the site automatically (using C or Java ) to see if homework has been posted. I like to code and i am curious as to if i can do this , but i am not sure where to begin.
I agree with Nick Delaney - network tab on Chrome (on a mac Option+Cmd+i) will show you what you want to see. Click on "Network" at the top of the panel that opens and check the "Preserve log" checkbox (if you don't do this, a full page load will clear out the history).
You should be able to see all the HTTP requests that go into logging in to the site and rendering the subsequent page. CSRF may or may not be an issue, but only experimenting will tell you.
For example, this is the login request for strava.com (a popular site for tracking fitness activities). This tells me that there is a form post passing email, password, authenticity_token (hm, wonder what this is? :), utf8 and remember_me fields. The successful response is a 302 redirect to https://www.strava.com/dashboard which also sets some cookies.
If I follow the redirect (the browser automatically does this for us) and look at the dashboard HTTP request (below the currently highlighted request) I will see the HTML that represents the dashboard page for a logged in strava user (me). If the data I want is on the dashboard, the challenge is in making a "correct" login request, following the redirect (with the cookies that were set on the login request) and parsing the response.
I have a page with a regular form:
<form method="post" action="pro.asp">
<input type="text">
<input type="submit">
</form>
when it gets to the pro.asp page it will do some server side actions like sending mail and then I need that page to send all the parameters in the post request to another website
I don't want to have another form filled auto and auto submit with javascript script
Is there a solution for that?
Do you have to make a POST to the other website?
The simplest thing to do may be to, when you are finished your own form processing, send the values to the other page as a GET.
To do that all you would need to do is end your processing with a response.redirect.
Response.Redirect ("http://somewebsite.com?value=X")