This is a discussion on "ASP form to check weather a form value is already in the database" within the Classic ASP section. This forum, and the thread "ASP form to check weather a form value is already in the database are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
ASP form to check weather a form value is already in the database
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
ASP form to check weather a form value is already in the database
i have made a script that gets the values from a form and adds it to a database but what i now want to do is add a check so if the value is already in the data base it will say Username is already in use please select another so if for instence some one fills out the username as tom and another person then trys to use tom as a username it will say that the username is already in use here is my process code
<% ' declare variables Dim UserName Dim Password Dim Email ' get posted data into variables UserName = Trim(Request.Form("UserName")) Password = Trim(Request.Form("Password")) Email = Trim(Request.Form("Email")) ' validation Dim validationOK validationOK=true If (Trim(UserName)="") Then validationOK=false If (Trim(Password)="") Then validationOK=false If (Trim(Email)="") Then validationOK=false IF (Trim(UserName)="EOF" or Trim(Password)="EOF" or Trim(Email)="EOF") Then validationOK=false & response.write("If you have entered <strong>EOF</strong> in any of the fields then.<br>") If (validationOK=false) Then Response.write("Please go back fill in all ") Response.write("the requied information<br>") Response.write("<a href=""signup.asp"">Click here</a> to return to the form.") ELSE 'Add account to Database Dim sConnection, objConn , objRS , strSQL sConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=xxxx; UID=xxxx;PASSWORD=xxxx; OPTION=3" Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open(sConnection) Set objRS = objConn.Execute("INSERT INTO accounts (user,password,email ) VALUES ('" & username & "','" & password & "','" & email & "')") 'Response.Redirect("index.asp") Response.write("<h2>Account Added!</h2>") Response.write("Account: " & UserName & "<BR>") Response.write("Password: " & Password & "<BR>") Response.write("Email: " & Email) END IF %> that form makes sure the vales from the form are not blank but i want it to check there not blank and the values dont already exist in the database.. any one help me |
|
|
|
#2
|
|||
|
|||
|
Re: ASP form to check weather a form value is already in the database
maybe this code might help you but if it don't, please let me know.
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Last edited by Monie; Oct 19th, 2007 at 05:29. |
|
#3
|
|||
|
|||
|
Re: ASP form to check weather a form value is already in the database
I'd have thought that you would need to create a second query of the database.
Something like
|
|
#4
|
|||
|
|||
|
Re: ASP form to check weather a form value is already in the database
Thanks.
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Add form components to a database | griffonwing | Classic ASP | 2 | Aug 18th, 2007 17:17 |
| form database | Barbs7349 | Starting Out | 1 | Aug 12th, 2007 13:22 |
| Check for valid email in JMail form | palgraphpres | Classic ASP | 1 | Apr 5th, 2006 19:43 |
| Submitting Web form results to a database | theproman23 | Databases | 2 | Jun 30th, 2005 13:21 |
| insert form to database | Monie | Databases | 1 | Aug 25th, 2004 02:59 |