Friday, May 21, 2010

ASP Experts: How to prevent duplicate registration?

I'm looking for if else statement whereby they check if the employee id has been registered.


If id has been found, error msg


else redirect to other page





It would be nice if you could provide the skeleton codes.

ASP Experts: How to prevent duplicate registration?
In my previous reply I gave you some links on where to get started and find code examples.





For this case try the following. Make an HTML textbox with name "userid". Then in the vbscript part:


%26lt;%


strID = Request.Form("userID")





Set rs = dbConn.Execute ("select 1 from registration where employeeID = "


%26amp; strID


)





if not rs.EOF then


response.write("error message%26lt;br%26gt;")


else


response.redirect("otherpage.asp")


end if


%%26gt;





This should get you started.
Reply:well its not hard... just think it through...





its just a feild check...


(not code below)





%26lt;format input for database entry%26gt;


%26lt;open database%26gt;


IF %26lt;check current userID set against input userID%26gt; FALSE


%26lt;process input%26gt;


IF %26lt;%26lt;check database updated properly%26gt;%26gt; FLASE


%26lt;return data update error%26gt;


ELSE


%26lt;Redirect to sucess%26gt;


END IF


ELSE


%26lt;return error%26gt;


%26lt;redirct to error page%26gt;


END IF


%26lt;Disconnect Data%26gt;





a structure like that would work all you need to do is use the current database BEFORE you send it an update command... that way no changes will be commited before your checks.

botanical garden

No comments:

Post a Comment