How to get user submission to post to page
Hey guys... I'm working on creating one of my first websites and currently have it only in HTML/CSS which is great for displaying some basic material on my site. However, I'd like to add in the option to submit something basic like a quote to the page. I'd like to st开发者_开发技巧art with just a simple form to submit a name and a quote and have it appear in the quotes section. I've looked up basic HTML forms and such but I'm not sure how to go between a basic HTML form and having that material appear on the page. Could anyone help me step through this or perhaps point me to a guide to accomplish this? Thanks.
You need a script which receives the posted information and some place to store the quotes. The script can be written in ASP.NET, PHP, python or whatever else your webserver supports and you want to learn. The database can be as simple as a directory with textfiles or a full-blown SQL database like postgresql or mssql.
When processing user-input you have to take care about security issues. The most common ones are:
- Cross-site scripting: When you present user-input to the user, it must not be interpreted as HTML and/or Javascript, to prevent malicious users from sending information from your trust-domain to them.
- SQL Injection: Always use the underlying database's parameter support to properly quote incoming data, to prevent malicious users from sending arbitrary commands to your database. See also this example.
as a java developer the way I would do this is:
- get the information from the html using JQuery
- than I would just a post to send to
- the servlet process what i need in servlet
- send back to JQuery the answer
- change my html with JQuery
Although I am sure there are much easier ways to do it with just PHP if you want to do this way, first thing i would master is making sure you can send things to the servlet and get an answer back.
look at this and see if you can get something to get sent back http://www.roseindia.net/servlets/HelloWorld.shtml
It might be a good idea to also look at JSPs http://java.sun.com/products/jsp/html/jspbasics.fm1.html
精彩评论