Hello, I have asp code for login page. And if the username and password is correct, I want to insert into the caporder table the correspondent values in the specific column. But now when I run once the code, it insert into several columns of the caporder table with the same value if the username and password are correct. Could any one suggest how to modify the code? Thanks!
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "Project"
dim username
username=Request.Form("user")
password=Request.Form("pass")
result=true
set rs = Server.CreateObject("ADODB.recordset")
sql="select username, password from customer"
rs.Open sql, conn
do until rs.EOF
for each x in rs.Fields
if username=x.value then
z=true
end if
if z=true then
if password=x.value then
session("ID")=username
conn.Execute "UPDATE Capproduct set cus_id='"&session("ID")&"' where ID='"&session("idnumber")&"' and sid='"&session.sessionid&"'"
conn.Execute "INSERT INTO Caporder VALUES ('"&session("ID")&"','"&session("idnumber")&"',getdate(),0,0,0,0,0,0,NULL,0,0)"----insert several times in caporder
Response.Write "<script>window.location='shipping.asp'</script>"
else result=false
end if
end if
next
rs.MoveNext
loop
rs.Close
conn.close
if result=false then
%>
<script type="text/javascript">
alert("The username and password are not matched, please type again! ");
</script>
<%
end if %>
<form name="form" method="post" action="login_after_cap.asp">
<p><font color="#0066FF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Username:
</strong></font>
<input type="text" name="user">
</p>
<p> <font color="#0066FF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>
Password: </strong></font>
<input type="password" name="pass">
</p>
<input name="Submit" type="submit" value="login">
<input type="reset" name="Cancel" value="Clear">
</form>