|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am having trouble getting this code to work. I want to check the email submited to my access db via post then if the email already exist then tell the user they need to choose another email address because this on already is in there. here is my code:
<% Response.Buffer = true dim conn,rsE set conn = Server.CreateObject("ADODB.Connection") set rsE = Server.CreateObject("ADODB.RecordSet") conn.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=members.mdb;" sqltext = "SELECT Email FROM Results WHERE Email=('" & request.Form("Email") & "') " rsE.Open sqltext,conn,3,3 WHILE NOT rsE.EOF rsE.MoveNext If rsE.EOF and rsE.Bof_then Response.Write("ok") end if 'do nothing because the Email does not already exists Else read through the recordset, see if Email matches another If rsE("Email") = Request.form("Email") Then Response.Write ("The Email you have entered already exist. Multiple accounts are not allowed Please use a different Email Address.") Response.End End If rsE.Close conn.Close %> Can someone check it and tell me what might be wrong with it. thanks -wasssup |
|
#2
|
|||
|
|||
|
What error message are you getting, can you specify which line errors out.
S- |
|
#3
|
|||
|
|||
|
At the time of my post I couldnt get any error due to my IE setting. I fixed that and was able to work the code til I got it working. I came up with a fix and have been running it. Here is that code: any one can use it if they like or if you can inprove it cool just share with me.. Thanks for your reply though. -wasssup
<% DIM strEmail, conn, rsE strEmail = Request.Form("Email") IF strEmail <> "" AND inStr(strEmail,"@") <> 0 AND inStr(strEmail,".") <> 0 THEN ' Enter form to database or send via email ELSE Response.Write "<p>Please click Back on your browser and complete the following field:</p>" IF strEmail <> "" THEN ELSE Response.Write "<b> Email</b><br>" END IF IF inStr(strEmail,"@") <> 0 THEN ELSE Response.Write "<b> You entered an invalid Email Address</b><br>" Response.End END IF IF inStr(strEmail,".") <> 0 THEN ELSE Response.Write "<b> You entered an invalid Email Address</b><br>" Response.End END IF END IF set conn=Server.CreateObject("ADODB.Connection") set rsE=Server.CreateObject("ADODB.RecordSet") conn.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=somedatabase.mdb;" rsE.Open "select Email from sometable where Email='" & strEmail & "'",conn,adOpenDynamic,1 'search the email 'assumption : one email for one person - no redundancy if not rsE.Bof and not rsE.Eof then 'already exists Response.Write"<b> The Email you have entered already exist. Multiple accounts are not allowed.<br> Please click on your back button and use a different Email Address.</b>" Response.End ELSE 'not exists End if rsE.Close conn.Close set rsE=Nothing set conn=Nothing %> |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft Access Help > help with if exist plz |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|