Data | page
Users often encounter annoying information when they visit the site, such as they often go to the next page without actually submitting the data to the form, or they often reach a page, which is transferred in the form of a query string, such as id=236454.
If the page doesn't get information, a big error can occur. This often occurs when the page looks for an ID or some other information, and the user is connected to the page using a bookmark or search engine. Therefore, the information required by the page is lost and the page ends.
You can check to see if any data has been submitted to control this situation, then display specific error messages depending on the situation, or perform other actions, such as redirecting to the desired page.
In the following 3 examples, only one message is displayed on the screen.
Place this code directly under the <% @ language= "VBSCRIPT"%>.
For a single form, use the Post method
<%
If Request.Form = "" Then
Response.Write ("< p align=" "Center" >< font face= "Arial" ">there was
error.< br > "& vbCrLf)
Response.Write ("No Data was posted.</font >
"& VbCrLf)
Response.End
End If
% >
for a form, use the put and get methods. This also applies to pages that are connected from a query string, such as? id=236454
<%
If request.querystring = "" Then
Response.Write ("< p align=" "Center" >< font face= "Arial" ">there was
error.< br > "& vbCrLf)
Response.Write ("No Data was posted.</font >
"& VbCrLf)
Response.End
End If
% >
To include the above example, do the following work. Although there are simple methods, this example will be a good way to learn basic principles for beginners.
<%
Isdata = 0
If Request.Form < > "" Then isdata = isdata + 1
If Request.QueryString < > "" Then isdata = isdata + 1
If isdata = 0 Then
Response.Write ("< p align=" "Center" >< font face= "Arial" ">there was a error.< br >" & vbCrLf)
Response.Write ("No Data was posted.</font >
"& VbCrLf)
Response.End
End If
% >
Or
<%
Isdata = "No"
If Request.Form < > "" Then isdata = "Yes"
If Request.QueryString < > "" Then isdata = "Yes"
If isdata = "No" Then
Response.Write ("< p align=" "Center" >< font face= "Arial" ">there was a error.< br >" & vbCrLf)
Response.Write ("No Data was posted.</font >
"& VbCrLf)
Response.End
End If
%>