Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Because it's ASP you have to separate what you want to run on the Server and what you want to run on the client. This isn't clear in your example. Hypothetically, I would assume your database to be behind a firewall and only accessible to the server.</p> <ul> <li>Anything that needs to be run on the server should be in &lt;% ... %> blocks</li> <li>i.e. your insertdata() routine probably belongs on the server (currently it's run from the client)</li> <li>Reference to Server and Session should be done on the server i.e. in the &lt;% ... %> blocks</li> </ul> <p>Some other notes:</p> <ul> <li>Since insertdata() doesn't return a value, use Sub instead of Function</li> <li>the body and form tags are the wrong way round</li> <li>in fact you don't need a form tag</li> </ul> <p>I'm going to guess that the supplied asp script is the server response to a form that you haven't showed us? It's not very clear, but perhaps you should have a read of <a href="http://www.w3schools.com/asp/coll_form.asp" rel="nofollow">ASP Form Collection</a> from w3Schools.</p> <p>Your <code>Function insertdata()</code> is incorrect. You're mixing client and server concepts. For example <code>Session.Contents</code> must be evaluated on the Server side and must be inside &lt;% ... %> block, whilst the insertdata() function itself belongs on the client side because, as you indicate you need it to react to a user event. I've reworked one line of your insertdata to illustrate the point I'm making:</p> <pre><code>Sub insertdata ... strSQL = "INSERT INTO Authen_User VALUES (" strSQL = strSQL &amp; "'&lt;%=Session.Contents("userKey")%&gt;'" strSQL = strSQL &amp; ",'&lt;%=Session.Contents("name")%&gt;'" strSQL = strSQL &amp; ",'&lt;%=Session.Contents("Type")%&gt;')" ... End Sub </code></pre> <p>When ASP sees your &lt;% ... %> it will replace them on the server with the proper values so that by the time the client sees it the substitute values will appear when the web page arrives on the client:</p> <pre><code>Sub insertdata ... strSQL = "INSERT INTO Authen_User VALUES (" strSQL = strSQL &amp; "'userKey12345678'" strSQL = strSQL &amp; ",'John Smith'" strSQL = strSQL &amp; ",'Mr')" ... End Sub </code></pre> <p>i.e. if the user does a <i>View page source</i> in his browser he will never see the &lt;%...%> in the source but the replaced values. So, when he clicks on the link it will do the right thing.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload