User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 391,558 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,692 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 1427 | Replies: 1
Reply
Join Date: Apr 2006
Posts: 3
Reputation: jaytaba is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
jaytaba jaytaba is offline Offline
Newbie Poster

Classic sql update question

  #1  
May 14th, 2007
I have a simple login screen where I want the user upon entering the correct userid/password , for his userid to be inserted into a table in a database so to keep track who visited his web page.

My ISP is supposedly has created a DS named "win5_zjconstructioninc_com"

but the code below is failing to insert a record to the database.
Can you experienced programmers be kind to take a look at the code below and suggest a course of action and that if I should take the issue up with my ISP.

Thanks in advance

J.


<%@ Language=VBScript %>
<%
Dim DB_CONNECTIONSTRING
DB_CONNECTIONSTRING = "Provider=SQLOLEDB;Data Source=sql.fastbighost.com;" _
& "Initial Catalog=win5_zjconstructioninc_com;UserId=win5_zjconstructioninc_com;Password=JFjwori8;" _
& "Connect Timeout=15;Network Library=dbmssocn;"
%>
<%
If request.form("login")="kal" and request.form("password")="walthers" then

session("userlogin") = "OK"
session("pass") = "OK"
Dim I
Dim iRecordToUpdate ' Id of deleted record
Dim strSQL ' String variable for building our query
Dim objRecordset
Set objRecordset = Server.CreateObject("ADODB.Recordset")
iRecordToUpdate = Request.QueryString("id")
iRecordToUpdate = Replace(iRecordToUpdate, "'", "''")

If IsNumeric(iRecordToUpdate) Then
iRecordToUpdate = CLng(iRecordToUpdate)
Else
iRecordToUpdate = 0
End If

strSQL = "SELECT * FROM userlogin WHERE id=" & iRecordToUpdate & ";"
objRecordset.Open strSQL, DB_CONNECTIONSTRING, adOpenKeyset, adLockPessimistic, adCmdText
If Not objRecordset.EOF Then
objRecordset.MoveFirst
objRecordset.Fields("text_field") = request.form("login")
objRecordset.Fields("integer_field") = CInt(Day(Now()))
objRecordset.Fields("date_time_field") = Now()
objRecordset.Update

End If
objRecordset.Close
Set objRecordset = Nothing
response.redirect "default2.asp"
End If
%>
<html>
<head>
<title>Mr. & Mrs. Kal Walther's Login Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../style.css" type="text/css">
</head>
<body text="#000000" bgcolor="#CED3D7" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="763" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" align="center">
<tr>
<td>
<table border="0" width="763" cellspacing="0" cellpadding="0" height="65" bgcolor="#E1E7EB">
</table>
</td>
</tr>
<tr>
<td align="center"><b><span class="headersmblue">California Dream <br><br>

&nbsp;Secure Login Area</span></b></td>
</tr>
<tr>
<td><br><br>

<table border="0" cellspacing="0" cellpadding="0" align="center" width="302">
<tr>
<td class="plaintext" width="302">
<form action="login.asp" method="post">
<table width="90%" border="0" cellspacing="3" cellpadding="0">
<tr>
<td colspan=2>&nbsp;</td>
</tr>
<tr>
<td class="plaintext">Login</td>
<td>
<input type="text" name="login">
</td>
</tr>
<tr>
<td class="plaintext">Password</td>
<td>
<input type="password" name="password">
</td>
</tr>
<tr>
<td colspan=2 align="center">
<input type="submit" name="Submit" value="Submit">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>

</td>
</tr>
</table>
</body>
</html>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2007
Location: http://sqltutorials.blogspot.com/
Posts: 20
Reputation: kokkee is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
kokkee kokkee is offline Offline
Newbie Poster

Re: Classic sql update question

  #2  
May 23rd, 2007
First, u didnt add in a form. you cant submit without a form.

Second, after u add in form, u need to add action="URL?login=kal&password=walthers"
If request.form("login")="kal" and
request.form("password")="walthers" then

i didnt check ur asp code, u try ist...
but i notice something wrong in ur asp code.
anywhere u try to add in form ist


Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP Forum

All times are GMT -4. The time now is 9:47 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC