valider data inden write
Hej igenSom før har jeg en databasen som der kan skrives til. Databasen indeholder 10 kolonner/felter men kun ét er vigtigt at få kontroleret når nye data skal indskrives. Feltet hedder "spiller" og kan have alle numre, men 2 må selvfølgelig ikke være ens. Hvordan kontrolerer jeg det via form-feltet?
Min koder ser sådan ud:
<%
set database = Server.CreateObject("ADODB.Connection")
connect="Driver={Microsoft Access Driver (*.mdb)}; DBQ="& server.mappath("../databaser/testdatabase.mdb")
database.Open connect
%>
<form action="write.asp" method="get" name="nypost">
<input name="spiller" type="text" size="50" maxlength="30">
<font size="2" face="Verdana, Arial, Helvetica, sans-serif">Spilletrøje
<strong>no</strong>.<br>
<br>
</font>
<font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="pabryst" type="text" size="50" maxlength="30">
</font><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> Paradedragt
<strong>bryst<br>
</strong><br>
</font> <font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="paryg" type="text" size="50" maxlength="30">
</font><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
Paradedragt <strong>ryg<br>
</strong><br>
</font>
<font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="trbryst" type="text" size="50" maxlength="30">
</font><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
Spilletrøje <strong>bryst<br>
</strong><br>
</font>
<font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="trryg" type="text" size="50" maxlength="30">
</font><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
Spilletrøje <strong>ryg<br>
</strong><br>
</font>
<font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="trærmeh" type="text" size="50" maxlength="30">
</font><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
Spilletrøje <strong>ærme H<br>
</strong><br>
</font>
<font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="trærmev" type="text" size="50" maxlength="30">
</font><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
Spilletrøje <strong>ærme V<br>
</strong><br>
</font>
<font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="shbag" type="text" size="50" maxlength="30">
</font><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
Shorts <strong>bag<br>
</strong><br>
</font>
<font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="shbenh" type="text" size="50" maxlength="30">
</font><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
Shorts <strong>ben H<br>
</strong><br>
</font>
<font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input name="shbenv" type="text" size="50" maxlength="30">
</font><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
Shorts <strong>ben V</strong></font><br>
<br>
<input type="submit" name="Submit" value="Gem post">
<input type="reset" name="Submit2" value="Slet alt">
</form>
<%
dim data
Set data=Server.CreateObject ("ADODB.Recordset")
data.Open "spiller", database, 2, 2
%>
<%
data.AddNew
data("spiller")=Request.QueryString("spiller")
data("pabryst")=Request.QueryString("pabryst")
data("paryg")=Request.QueryString("paryg")
data("trbryst")=Request.QueryString("trbryst")
data("trryg")=Request.QueryString("trryg")
data("trærmeh")=Request.QueryString("trærmeh")
data("trærmev")=Request.QueryString("trærmev")
data("shbag")=Request.QueryString("shbag")
data("shbenh")=Request.QueryString("shbenh")
data("shbenv")=Request.QueryString("shbenv")
data.Update
Response.Redirect("readall.asp")
%>