Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


this is the code

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,1579
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> this is the code
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 this is the code - 11/5/2004 1:46:48 PM   
  rajesh kumar deol

 

Posts: 2
Score: 0
Joined: 11/5/2004
From: Philippines
Status: offline
im using this code im register.asp code but the problem is it does'nt tell the user if the name he has entered is already in use
it just redirect the user to login.asp page
here is the source code

<%
Option Explicit
Dim strError, strSQL, strSEL, x
'see if the form has been submitted
If Request.Form("action")="register" Then
'the form has been submitted

'// validate the form

'check if a username has been entered
If Request.Form("username") = "" Then _
strError = strError & "- Please enter a username<br>" & vbNewLine

'check if a password has been entered
If Request.Form("password") = "" Then _
strError = strError & "- Please enter a password<br>" & vbNewLine

'check if the passwords are the same... but don't display it if the password field is blank.
If Request.Form("password") <> Request.Form("password_confirm") _
And Request.Form("password") <> "" Then _
strError = strError & "- Your passwords do not match<br>" & vbNewLine
'// check if an error has occured
If strError = "" Then
'continue
'include database connection code
%>
<!--#include file="inc-dbconnection.asp"-->
<%
On Error Resume Next
'//check if user name exists in the database table "members"
strSEL = "select * from members where username = " & request.form("username")
x = objConn.execute(strSEL)
if x="username" then '//username exist
strError = strError & "- That username is already in use. Please choose another<br>" & vbNewLine
Response.Write ("strError")
strError = strError & "- An error occured. " & Err.Number & " : " & _
Err.Description & "<br>" & vbNewLine
Response.Redirect "Register.asp"
Response.End
else
'// create the SQL
strSQL = "INSERT INTO members ([username],[password]) VALUES " & _
"('" & fixQuotes(Request.Form("username")) & "','" & _
fixQuotes(Request.Form("password")) & "')"
'// run the SQL
objConn.Execute strSQL
Response.Redirect "login.asp?msg=" & Server.URLEncode("Thank you for registering")
Response.End
end if
'// check for an error
'// ATTENTION: this should be changed depending on the database provider
If Err.Number = -2147467259 Then
strError = "- That username is already in use. Please choose another<br>" & vbNewLine
ElseIf Err.Number <> 0 Then
strError = "- An error occured. " & Err.Number & " : " & _
Err.Description & "<br>" & vbNewLine
Else
'record created... redirect
Response.Redirect "login.asp?msg=" & Server.URLEncode("Thank you for registering")
Response.End
End If

'restore standard error handling
On Error Goto 0

End If
If strError <> "" Then
'output the error message
'add extra HTML...
strError = "<p><font color=""#FF0000"">The following errors occured:" & _
"</font><br>" & vbNewLine & strError
End If
End If

Function fixQuotes(strData)
fixQuotes = Replace(strData,"'","''")
End Function
%>
<html>
<head>
<title>My Website's Registration Page</title>
</head>
<body>
<h1>Member Registration</h1>
<p>Please fill out the following form to register as a member, and
gain access to our members area.</p>
<%=strError%>
<form action="register.asp" method="POST">
<input type="hidden" name="action" value="register">
<table border="0">
<tr>
<td><b>Username</b></td>
<td><input type="text" maxlength=20 name="username"
value="<%=Server.HTMLEncode(Request.Form("username"))%>"></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input type="password" maxlength=20 name="password"
value="<%=Server.HTMLEncode(Request.Form("password"))%>"></td>
</tr>
<tr>
<td><b>Password Confirm</b></td>
<td><input type="password" maxlength=20 name="password_confirm"
value="<%=Server.HTMLEncode(Request.Form("password_confirm"))%>"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Complete Registration"></td>
</tr>
</table>
</form>
</body>
</html>
 
 
Post #: 1
 
 Re: this is the code - 11/15/2004 8:54:48 AM   
  wils0n

 

Posts: 14
Score: 0
Joined: 10/27/2004
From:
Status: offline
Line 38: Response.Redirect "Register.asp"

If buffering is set as "on" by default on your Web server, you can't see the message because you are redirecting the user before the message can be displayed.

Read up on how the server handles redirects and streaming content to the client.

(in reply to rajesh kumar deol)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> this is the code Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts