Home >Web Front-end >HTML Tutorial >How to submit a pure HTML page, pass parameters, and verify identity_HTML/Xhtml_Web page production

How to submit a pure HTML page, pass parameters, and verify identity_HTML/Xhtml_Web page production

WBOY
WBOYOriginal
2016-05-16 16:39:502205browse

Since the project requires a set of questionnaires, but the customer requires that the questions of the questionnaire must be pure html tags, we are faced with a series of problems

How to submit page 1
After the user has completed the questionnaire, how to submit the survey results?

2 How to pass parameters to the page
After multiple people submit the same questionnaire, the manager will check the questionnaire and how to pass the parameters to ensure that the data seen is the specified one Questionnaire for people. In fact, this problem can be solved by using the simplest query string in asp.net, but in pure html, how to pass parameters?

3 How to verify user identity
Only after the user logs in can the answer be answered. How to verify whether the user is logged in?
Is the entire system implemented using html? Can it be done? It seems not possible. After all, the submitted data needs to be saved in the database. This may not be accomplished by pure HTML.
So the basic idea is to use html static web pages in the frontend, but csharp code must be used in the backend.

How to submit 1 page
In fact, pure HTML can be submitted, mainly through the form tag.
For example, after the following code is submitted to savedata.aspx, all the data input by the user can be obtained, and after processing, it is saved to the database. It can be submitted through ajax or through the input tag whose type is submit.

Copy code
The code is as follows:




Copy the code
The code is as follows:


First name:

Last name:





2 How to pass parameters to the page
In fact, the easiest way to pass parameters to the page in asp.net is through query characters string, but the pure HTML webpage is a static webpage, and there is no background for the corresponding page. How to pass parameters
For example, in the same set of questionnaires, both Zhang San and Li Si answered the questionnaires. The administrator wants to check Zhang San’s questionnaire. How to pass Zhang San’s questionnaire? Are the answers to three reassigned to the questions in the questionnaire?
Since html is a static page, if you want to read data, you must dynamically read the answer through ajax, and then modify the static page. But how do you pass parameters that represent a certain person?
In fact, it is still through the query string, but the method of analyzing the query string has changed from the backend to the frontend, to analyzing the query string through js, and then reading the data through ajax.

Copy code
The code is as follows:

function QueryString(name)
{
var sURL = window.location.search
var re = new RegExp("" name "=([^&?] )", "ig");
var result= re.exec(sURL );
if(result)
{
var temp= result[0].split('=');
return temp[1] ;
}
else
{
return "";
}
}

Of course there is another way, because reading data must go through the background, so it can be based on the information in the Session. Get the parameters, but if there is no relevant information in the Session, you can only use the query string.
For example, in the example here, you can only use query strings.

3 How to verify user identity
Since the entire system cannot be completed with just HTML, the front-end display is pure HTML, and the background is csharp code, naturally there is Session, and of course there is User identity can be verified. If you need to determine whether a static html page has expired, you can call the background method through ajax and determine whether the user is logged in and whether it has expired based on whether the Session exists.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn