Capture User Names in Web Forms?

R

RoadKill

I have anonymous web browsing turned off on my subweb where I keep my
webforms. Using FrontPage we have been able to capture the User Name of our
users whenever they submit anything via these forms.

They've transitioned us from FrontPage to SharePoint Designer now and the
ASP.NET services just aren't working on my server.

Consequently I am building my forms in ASP. How do I capture those user
names if this is my code presently:

<%@ Language = "VBScript"%>
<%
'Declare all local variables
dim conn
dim rs
dim strconn
dim strsql

strsql = ""
'set connection string to local variable-I use a DSN-less connection
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" &
Server.MapPath("fpdb/Evaluation.mdb")

'build the sql statement based on the input from the form
strSQL = "INSERT INTO Results(Supervisor, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8,
Q9, Q10) Values('" & request("Supervisor") & "', '" & request("Q1") & "', '"
& request("Q2") & "', '" & request("Q3") & "', '" & request("Q4") & "', '" &
request("Q5") & "', '" & request("Q6") & "', '" & request("Q7) & "', '" &
request("Q8") & "', '" & request("Q9") & "', '" & request("Q10") & "')"

'Set connection object
set conn = server.createobject("adodb.connection")
conn.open strconn
'Use the execute method of the connection object the insert the record
conn.execute(strSQL)
conn.close
set conn = nothing
%>


Somethign to do with this, I'm sure: Request.ServerVariables("User_name")
 
S

Stefan B Rusynko

Create a hidden form field in your form as say:
<input type ="hidden" name="UserName" value ="<%=Request.ServerVariables("AUTH_USER")
%>">
Note - depending on your server security setup for authentication you may need to try
Request.ServerVariables("LOGON_USER")

See http://www.devguru.com/Technologies/asp/quickref/request_servervariables.html

And then add that new field (UserName) to your strSQL statement list of variables/values

PS
You really should not be using the global Request
(inefficient and open the page to sql injection)
as just:
request("FormFieldName")
- but instead should be using:
Request.Form("FormFieldName")
for all your form fields
See http://www.devguru.com/Technologies/asp/quickref/request.html

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


I have anonymous web browsing turned off on my subweb where I keep my
webforms. Using FrontPage we have been able to capture the User Name of our
users whenever they submit anything via these forms.

They've transitioned us from FrontPage to SharePoint Designer now and the
ASP.NET services just aren't working on my server.

Consequently I am building my forms in ASP. How do I capture those user
names if this is my code presently:

<%@ Language = "VBScript"%>
<%
'Declare all local variables
dim conn
dim rs
dim strconn
dim strsql

strsql = ""
'set connection string to local variable-I use a DSN-less connection
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" &
Server.MapPath("fpdb/Evaluation.mdb")

'build the sql statement based on the input from the form
strSQL = "INSERT INTO Results(Supervisor, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8,
Q9, Q10) Values('" & request("Supervisor") & "', '" & request("Q1") & "', '"
& request("Q2") & "', '" & request("Q3") & "', '" & request("Q4") & "', '" &
request("Q5") & "', '" & request("Q6") & "', '" & request("Q7) & "', '" &
request("Q8") & "', '" & request("Q9") & "', '" & request("Q10") & "')"

'Set connection object
set conn = server.createobject("adodb.connection")
conn.open strconn
'Use the execute method of the connection object the insert the record
conn.execute(strSQL)
conn.close
set conn = nothing
%>


Somethign to do with this, I'm sure: Request.ServerVariables("User_name")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top