post to remote url from stand-alone html file - html

I am trying to post to a remote url from a local html file on my desktop, but the server doesn't seem o be receiving any post data?

Oopsy, The designer didn't preserve the form input name attributes... (I just assumed they did)

A form tag with action set to any web address will send to it:
<form method="post" action="http://example.com/myscript.php">
Take another look over your code to make sure you haven't forgotten anything. Showing us the HTML might help answers.

Related

See HTML response in chrome network

Hello when I send my html page with google chrome I can't see the path in the link Bar Though I use the method get and when I open the network angle I can't find the query request either enter image description here
On the first view is see that your request goes again a html page. Then you will get as response the html. But i suggest you will send some data. Then you have to add in every form element a name selector. Like <input name="username" ...>.
Then you need a endpoint which can handle your request. A HTML side cant do that. You need a serverside endpoint. Like api.php etc.

How to find out what url HTML button submits to

So I'm scraping a website (instacart.com) and it requires a zip code to determine what data it displays. I want to use Python requests to post an arbitrary zip code. The only problem is I don't know what url to post it to and whether it requires any other arguments like an authenticity token or a user cache key. The zip code is entered via an text box that looks like this:
<form data-radium="true">
<input id="postalcode-16749"
name="postal_code"
type="text"
aria-invalid="false"
aria-describedby=""
autocomplete="on"
placeholder=""
data-radium="true"
value="" style=(super long block of css stuff)>
</form>
and then posted via a button that looks like this:
<button type="submit"
data-radium="true"
style="touch-action: manipulation; (long block of more css)">
Continue
</button>
I don't know a lot about web programming, but I was taught in school that HTML forms would look more like this: <form action="/action_page.php" method="get"> and you could use the action attribute to find where it was posting to. Is there a way to use the developer console to find what I'm looking for? How can I post a zip code to this website with Python?
Edit: I did a little more digging and I found that the request payload is {"current_zip_code":"some_zip_code"}, and that it's actually not using POST, it's using PUT. There's still a problem though, the request url looks like this: https://www.instacart.com/v3/bundle?source=web&cache_key= and then there's a different code each time for the cache_key. How do I know what url to post to?
I'm posting this answer in case anyone tries to do a similar thing. I found the url the button posts to and its parameters by looking in the network tab of the developer console and clicking the button. Then I ran into the problem that the url it sends the PUT request to changes every time, always ending in a different cache_key.
The solution was to use a python module called seleniumwire to simulate a browser and then grab all the network traffic. From there I looped through it and found urls containing cache_key= and stored everything after that as a string. Then tacked that string to the end of this url: https://www.instacart.com/v3/bundle?source=web&cache_key= and went back to using requests.
hope this helps someone!

What happens when submitting an html form? (the process behind the scenes)

Can someone please tell me what happens behind the scenes in the following case (i.e. explain the whole technical process)?
<form method="get" action="#">
<input type="text" name="d" value="flowers">
<button type="submit">send</button>
</form>
In this case after one has clicks on “send” a new webpage opens saying: "You have searched for "flowers" " and an image of some flowers below.
In the browser tab right after the URL of the newly opened page there is
“/?s=flowers”. What is that?
Thank you in advance for your answers!
When you click Send, the page data specified in the form information and values is passed to the server via HTTP.
The /?s=flowers is the GET data being passed back to the server. Although, based on the form code you've provided, the "name" of that value is d. So the URL would actually have /?d=flowers
The PHP or server side language then handles that information to do specific tasks. It can access the info using the name "d". This method of sending data is called GET, there are also other ways of doing this. The most common, POST, does not display the data in the URL and send the data through HTTP headers.
The code you've shown has an action of "#" which means the HTTP method is being sent the same page. Meaning this page code would have some PHP located in it. This can also be done by using a seperate file, such as action='send.php'

submitting a form that doesn't has an action

I am trying to submit that form on the site from java. up till now i found the POST-DATA that is send using httpFox. but the problem that the form doesn't include an action that i could use. here is the link
http://tamarod.com/index.php?page=english
the data that is sent on submit is
Member_Name=&National_ID=&governerate_id=0&district_id=&Email=&Date_Of_Birth=&Submit=I+Accept
but i tried adding this line beside the url on the browser to try it but nothing happens..
I figured out the problem. I was missing SetDoInput() and SetDoOutput() in my HttpConnection. so i can POST and GET data.

How do you post to a secure service from unsecure page without using fully qualified domain name?

I would like to post have a form that sits on a non secure page without using the fully qualified domain name.
http://www.domain.com/page.aspx
post to a secure service on the same domain
https://www.domain.com/service.aspx
I am currently doing this which works.
<form action="https://www.domain.com/service.aspx" id="formId" method="POST">
The main issue is that we have qa versions of the site
http://qa.domain.com/page.aspx
https://qa.domain.com/service.aspx
the form here looks like
<form action="https://qa.domain.com/service.aspx" id="formId" method="POST">
and there is some publishing issues because when we publish from qa to prod we have to manually update the domain name.
What I'd like to do is somehow point to
<form action="/service.aspx" id="formId" method="POST">
but make the form use the prefix https. We can dynamically write the URL in the form, but I was looking for a way to do it with HTML.
Thanks
You can't do this with URL syntax. You must always restate anything to the right of the component of a URL that you change when constructing relative URLs.
You could generate the URLs programmatically (preferably with server side code).
Note, that as per my comment on the question, you shouldn't do this.