PDA

View Full Version : Check Password


Jason.K
11-12-2002, 08:06 AM
Hey, I am not sure if this is an ASP or JavaScript question but I thought I would post it her this the project is for ASP.

I am doing a course and I am learning ASP. I need to update products for a database by a HTML form. The HTML form has a password text box and I need it to check the password is correct when it goes on to the add products asp page. The password only needs to be in the code, doesn't need to be secrue. The password text box name is password.

I am not sure how to do this. If it was checking the password on the same page the password was entered I could use javascript like this:

if(password.value != password name)
{
and action here
}
But I need to check it on the next page where the products are added to the database, the page after the user has clicked on submit.

Could someone please give me a suggestion

thanks in advance, jason

glenngv
11-12-2002, 08:12 AM
Better to do in ASP

<%
if request.form("password")<>"this is the password" then
response.write("<html><head><title>Wrong password</title></head><body><form>Wrong password!<p><input type=button value=Back onclick='history.back()'></form></body></html>")
response.end
end if

'other codes here
%>

Jason.K
11-12-2002, 08:19 AM
Originally posted by glenngv
Better to do in ASP

<%
if request.form("password")<>"this is the password" then
response.write("<html><head><title>Wrong password</title></head><body><form>Wrong password!<p><input type=button value=Back onclick='history.back()'></form></body></html>")
response.end
end if

'other codes here
%>

Thanks for that, I was just wondering what the <> is for on the top line?

I have code on the same page which will be under this code that adds the products to the database, if the the password is incorrect will the data still be added into the database or will the it stop if the password is incorrect?

glenngv
11-12-2002, 08:25 AM
<%
if request.form("password")<>"this is the password" then
response.write("<html><head><title>Wrong password</title></head><body><form>Wrong password!<p><input type=button value=Back onclick='history.back()'></form></body></html>")
response.end
end if

'other codes here
%>

<> means not equal, so if the password entered by the user is not equal to the password you set, it will display an error message and response.end will cause the processing of other scripts to stop.
of course, you have to change "this is the password" to your desired password.

Jason.K
11-12-2002, 08:27 AM
Originally posted by glenngv
<%
if request.form("password")<>"this is the password" then
response.write("<html><head><title>Wrong password</title></head><body><form>Wrong password!<p><input type=button value=Back onclick='history.back()'></form></body></html>")
response.end
end if

'other codes here
%>

<> means not equal, so if the password entered by the user is not equal to the password you set, it will display an error message and response.end will cause the processing of other scripts to stop.
of course, you have to change "this is the password" to your desired password.

Thanks for your help, I am only new to ASP and you have really helped me other out.

glenngv
11-12-2002, 08:39 AM
you can read asp tutorials at:

http://www.w3schools.com/asp/

whammy
11-14-2002, 12:04 AM
That site is like my bible. :)

Whenever I need to look up some syntax or get a quick refresher on something, or even learn something entirely new, that's usually the first place I go.

Although if I need a more detailed explanation on something, or if it's something like javascript where the answers are not readily available to my particular situation, I'll come here to post or visit javascriptkit.com. :)

If you were to go through that whole site and learn every tutorial, while playing with all of the concepts on your own at the same time, you'd end up having quite a broad knowledge base, I think.

Whatever you do, memorize or bookmark that link:

http://www.w3schools.com

P.S. The funny thing about it is the guy who introduced me to that site originally wasn't even a programmer, and ended up getting fired from our company. ;)

:)