
December 19th, 2000, 11:51 PM
|
|
Contributing User
|
|
Join Date: Dec 2002
Posts: 14,575
  
Time spent in forums: < 1 sec
Reputation Power: 22
|
|
|
<i><b>Originally posted by : Lee Campbell (Lee_c@ihug.co.nz)</b></i><br />This might kick start your efforts here. I do the same thing in one of my websites that I am developing now<br /><br />First I get the user name and password from the previous pages form<br /><br /><%<br />Name=Request.Form("ID")<br />Assigned=Request.Form("Password")<br />%><br /> Next I declear the SQL statement that is going to check the DB (Database) if there is such a user<br /><br /><%<br />SQLUSER="SELECT userID, password FROM ADMIN WHERE userID = '" & Name & "' AND password = '" & Assigned & "'"<br />%><br /><br />Next I open the connection to My DB<br /><br /><%<br />set connresult = server.createobject("ADODB.Connection")<br />connresult.open "DATABASENAME"<br />%><br /><br /> And now make the query to the DB<br /><br /><%<br />set user=connresult.execute(SQLUSER)<br />%><br /><br />Now To see if the user exists check if 'user' is at the end of its records or 'End Of File' (eof)<br />(We know it is at the start of the records because we haven't told it to <br />move to the next one yet, but if it is at the end of the records as well then<br />there must be no records!)<br /><br /><% If user.eof then<br /> response.redirect "Homepage.html"<br />else<br /> session("access")=True<br /> response.rediect "destinationpage.asp"<br />end if %><br /><br />After the else statement I have set a Session Variable "access" (can be named <br />anything) to true. Session Variables hold their values across pages so at the <br />destination page (here called destinationpage.asp) jsut check if sesion("access")=true.<br />If it doesn't use <br /><% response.redirect " " %><br />to redirect the user to an error page or back to the homepage.<br /><br />------------<br />william at 12/19/2000 8:27:47 AM<br /><br />I am having a problem with creating a script that verifies whether or not a user has an account in a database table. If so he or she gets access; if not they are redirected to the home page. Below are my problem.<br /><br />1. The user is supposed to create an account with the username and password of thier choice. The data goes into a database table.<br /><br />2. Then they are directed to a log in page.<br /><br />3. Next, they log in with the created username and password to access a secure page.<br /><br />4. If they have an account they get access to the page, but if they do not have an account they get redirected back to the home page.<br /><br />The problem I am having is the actual script that queries the database table and directs them to the secure page and redirects them if they do not have an account.<br /><br />Can anyone help? I am slowly getting the hang of asp, but am very confused as I am new to programming with asp.<br /><br />Thanks for all of your help.
|