I have a simple form that collects names in time slots. The form lists all the time slots with the names and blank spots available.

The problem I'm running into is people are overwriting other names so they can get a time slot they want. I've done some research and think concurrency checks are the way to go, but am lost as how to impliment these.

The code I have is:

<%
Set rs = Server.CreateObject("ADODB.RecordSet")
SQL = "SELECT * FROM OpenEnrollment2 WHERE ID = '1'"

rs.Open SQL, conn, AdOpenStatic, AdLockOptimistic

If request("Submit") <> "" then

SQL = "UPDATE OpenEnrollment2 SET "

SQL = SQL & "C1 = '" & replace(request("C1"), "'", "`") & "', "
SQL = SQL & "C2 = '" & replace(request("C2"), "'", "`") & "', " 
SQL = SQL & "C3 = '" & replace(request("C3"), "'", "`") & "', " 
SQL = SQL & "C4 = '" & replace(request("C4"), "'", "`") & "', " 
SQL = SQL & "C5 = '" & replace(request("C5"), "'", "`") & "', " 
SQL = SQL & "C6 = '" & replace(request("C6"), "'", "`") & "', " 
SQL = SQL & "C7 = '" & replace(request("C7"), "'", "`") & "', " 
SQL = SQL & "C8 = '" & replace(request("C8"), "'", "`") & "', " 
SQL = SQL & "C9 = '" & replace(request("C9"), "'", "`") & "', " 
SQL = SQL & "C10 = '" & replace(request("C10"), "'" "`") & "', " 

SQL = SQL & "WHERE ID = '" & rs("ID") & "'"
conn.Execute SQL

response.redirect("confirm.asp")
End If
%>

And the listing code is:

<input type="text" name="C1" size="20" value="<% = rs("C1") %>">

I'm new at this, so this may not be the way to do this type of form, but it is what I came up with. I have an established record in the database (ID = '1') and just have the form update that dataset.

I want to make it so Person2 cannot overwrite Person1's name when Person2 goes to sign up for a time slot.

Can someone help me in this direction without slamming a newbie?

Thanks in advance.

Can I add something like this?

If rs("C1") = "" then 
response.write "<input type=""text"" name=""C1"" size=""20"">"
Else
response.write rs("C1")
End If

So if the field is blank it will put the text box there, but if the field has a value it will just put the value, no text box.

Ok, the snippet of code above does what I want it to do for the form, if the field is filled in it shows as just the person's name, no text box. If the field isn't filled in, then it shows the text box.

The problem is when I submit a new name, the other names already on the form disappear.

So, now I'm confused...Help!

Never mind, I solved the problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.