See the beautiful ASP

Source: Internet
Author: User

Looks beautiful

On the forum, a mm post asked a question. I found a very obvious mistake at a Glance. It may be her mistake. shortly after I posted the post, she contacted me with the message! Error still

Original post:

Http://topic.csdn.net/u/20080609/13/ab9951e1-6195-4513-a619-b0e304af7c5a.html

Without the consent of someone else, I copied the code from someone else :)

<% Set rst = server. createobject ("ADODB. recordset ") rst. open "select * from users where u_user = '" & request. form ("f_user") & "'", Conn, 1, 1, if rst. recordcount> 0 then response. write "username:" & request ("f_user") & "already exists. Please click back to return to the previous page! "Response. end rst. close set rst = nothing Conn. close set conn = nothing else rst. open "users", Conn, 1, 3 rst. addnew RST ("u_user") = request ("f_user") RST ("u_code") = request ("f_code") rst. update rst. close set rst = nothing Conn. clsoe set conn = nothing end if %>

Let's analyze it together!

1. Check whether the user name already exists! If yes, you will be prompted. Otherwise, you will be registered.

2. Since there are two businesses, let's look at them one by one.

Set rst = server. createobject ("ADODB. recordset ") rst. open "select * from users where u_user = '" & request. form ("f_user") & "'", Conn, 1, 1' If rst. recordcount> 0 then response. write "username:" & request ("f_user") & "already exists. Please click back to return to the previous page! "Response. End RST. Close set rst = nothing conn. Close set conn = nothing

Now let's assume that it only executes one business, so I commented out the line if, so let's continue to look at the business.

 

<% Set rst = server. createobject ("ADODB. recordset ") rst. open "select * from users where u_user = '" & request. form ("f_user") & "'", Conn, 1, 1' If rst. recordcount> 0 then if 1 <> 1 thenresponse. write "username:" & request ("f_user") & "already exists. Please click back to return to the previous page! "Response. end rst. close set rst = nothing Conn. close set conn = nothing else rst. open "users", Conn, 1, 3 rst. addnew RST ("u_user") = request ("f_user") RST ("u_code") = request ("f_code") rst. update rst. close set rst = nothing Conn. clsoe set conn = nothing end if %>

Comment out the original if judgment. We use a Java-like assertion to short-circuit the code and let the execution flow jump to the else block for execution. if you are not very clear about it, You can delete it like the code above (if code), like this:

<% Set rst = server. createobject ("ADODB. recordset ") rst. open "select * from users where u_user = '" & request. form ("f_user") & "'", Conn,' Here is the deleted Part Of The placeholder rst. open "users", Conn, 1, 3 rst. addnew RST ("u_user") = request ("f_user") RST ("u_code") = request ("f_code") rst. update rst. close set rst = nothing Conn. clsoe set conn = nothing end if %>

Now, anyone who writes ASP a little bit can find an error:

RST. Open "select * from users where u_user = '" & request. Form ("f_user") & "'", Conn, 1, 1

RST. Open "users", Conn, 1, 3

What will happen after these two rows are executed (or when they are not completed?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.