How to Store & Retrieve Data With HTML

Save

A website has a number of uses for a webmaster including the ability to publish information and files to visitors around the world. But you can also use a website to store and retrieve data from visitors by entering simple HTML code. In both cases you need to write code to create an HTML form.

Store Data---Upload Form

  • Create a new HTML file in Notepad or a similar HTML editor program. Name it "storedatafile.php" and start typing in HTML code. Enter <html><body> <?php (new line) move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'], (new line) "../storedfiles/{$_FILES['uploadFile'] ['name']}") (new line)?> </body></html>. Replace the words "(new line)" in the code with a hard return (just press "Enter"). Save and upload the file to your web server. This file tells the server to upload the visitor's file to a new "storedfiles" folder on your web server.

  • Create another separate HTML file---name it "store.html" or something similar. Enter text in the <body> tag to indicate to the visitor that this form is for uploading data files to your web server.

  • Go down a line and enter <form action="storedatafile.php" method="post">Enter File Name: <input type="file" name="uploadFile"><input type="submit" value="Upload File"></form>. This code creates the upload form that contains a blank box where the visitor can browse for his data file to upload.

  • Save the HTML file and upload it to your server to display this page, which allows you to store files from visitors on your web server.

Retrieve Data---Create Standard Form

  • Download an ASP script file from a website that offers free or paid web scripts (see "Resources" for an example). Make sure the script specifically allows you to retrieve information from a visitor in a web form and receive an email containing the information. Save the ASP file as "retrieveinfo.asp" and upload it to your web server.

  • Create a new HTML file. Enter <form name="input" action="retrieveinfo.asp" method="post"><input type="hidden" name="my_email" value="email@yourwebserver.com"> Information 1: <input type="text" name="info1" /><br />Information 2: <input type="text" name="info2" /><input type="submit" value="Submit" /></form> inside of the <body> tags. Keep in mind that you can replace "Information 1" and "info1" as well as "Information 2" and "info2"in your code with your own desired pieces of information that you want to retrieve from the visitor. For instance, you can ask for a name, address, or phone number. Replace "email@yourwebserver.com" with your own email address and enmake sure that all name tags (like "my_email" and "info1") match up with the name tags listed in the ASP file you download (read documentation listed by the script provider you chose in Step 1 for exact details).

  • Save the HTML file and name it "retrieve.html" or something similar. Upload this file to your web server as well. When the user enters his data into this form you'll receive an email containing the information he entered.

Tips & Warnings

  • You should only send the link to your upload form to customers on a case-by-case basis instead of publicizing the link on your website. This is to reduce the chance that random visitors upload files that you don't recognize to your web server.

References

  • Photo Credit Comstock Images/Comstock/Getty Images
Promoted By Zergnet

Comments

Resources

You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!