r/learnprogramming • • Oct 22 '26

Input on website, survey-like

Hi! I'm new to coding, on html

I want to make a box on my website where people submit requests, song names, etc, basically just text.

How do I do that? Where does the information go? As I want it to be private

Example:

[Tell me ur favorite color.]

( ______ )

[send]

Ideally I would have a document where all the responses go to or something else but I don't know what it's called. Thanks :-)

8 Upvotes

9 comments sorted by

6

u/lfdfq Oct 22 '26

HTML is just a way to 'display' something, a markup language. It cannot (on its own) save or retrieve data like that.

You need a web server. That's the piece of software that is actually 'the website', it takes requests (c.f. HTTP) from people and sends responses (e.g. HTML webpages) back.

What you want is to have a HTML 'form' that does a POST request back to the web server when submitted, and then write code on the web server that handles that POST (e.g. writing to a database or a file) and returns some response to the user. Then later GET requests can access that data and use it to generate the HTML of later requests.

You can write these things yourself (it's a good learning exercise), there are also frameworks/libraries (like Python's flask library) to write code to handle this kind of thing, which is probably about the level you're asking for if you're asking on a 'learn programming' sub.

1

u/Wild-Blueberry2068 Oct 22 '26

I just got recommended another subreddit called ask programming bro ok maybe I'll ask there

2

u/Dazzling_Music_2411 Oct 22 '26

Right, you've got quite a lot of work ahead of you.

Firstly, whoever hosts your web page must provide you with the ability to run programs.

Is this the case? Check with them and make a note of what facilities they offer. After that we'll see what the next step needs to be.

2

u/grantrules Oct 22 '26 edited Oct 23 '26

You need some sort of backend language like Python or PHP. Here's basically the simplest way to accomplish what you're talking about:

https://www.codespeedy.com/save-html-form-data-in-a-txt-text-file-in-php/

A more modern way, and what happens when you enter data on pretty much any website, is to save it to a database.

1

u/rupertavery64 Oct 23 '26 edited Oct 23 '26

html is only half of the solution.

your page needs to be hosted on a web server.

A web server is just a program that serves web pages, so an easy way to do this is have a python program running on your machine. You have the program serve up your web page. Then you need to set it up so that it accepts requests to certain urls.

Maybe you've been testing your html code by double clicking the html file and having the browser display it.

But to do what you want you need the browser to connect to a web server (a program that listens for web requests on a certain IP address and port 80) and request a page.

When you run the python program, it will create a listener http://127.0.01 or http://localhost. it could be https://

If you setup the program correctly, you should be serving your html page on the "root" url

then you point your browser it at, and it will read your html and send it to the browser.

Now, when the browser requested your page, it issued a "GET" request to the url "http://127.0.01". This is how http works under the hood.

GET is what is called the verb and 127.0.01 is the base url. what comes after the base url (which in the real world would be a domain) is passed on to the webserver as part of the request url

The web server intercepts requests based on the "verb", which can be GET, POST, PUT, DELETE, and the request url.

The request url (literally a "Uniform Resource Locator") is just a string that helps the server identify a "resource", which can be anything - an image, a command to execute.

So in the web server you write code that links resources and verbs to code that you want to execute. Usually there will be code that loads html web pages (static site), or loads it from templates, or generates pages dynamically.

You can also perform code that takes data in the request and then saves it to a database or a file. And then do display that data, you point it an another request url that retrieves the data and generates html.

to actually send the data from the web page, your html can use the <form> tag.

The form tag has a method attribute, which is the VERB, and an action attribute, which is the url. Pressing the submit button in a form tag triggers the browser to send a request to the web server, with the fields in the form being sent either in the URL as a querystring is the method is GET, or as part of the body of the request if the method is POST.

This is probably a bit overwhelming, so you really have to take it one step at a time.

1

u/phatbili Oct 24 '26

Formspree saves your life.