Computing.Net > Forums > Web Development > ASP simple question

ASP simple question

Reply to Message Icon

Original Message
Name: hawkins6423
Date: July 22, 2004 at 18:47:37 Pacific
Subject: ASP simple question
OS: win xp pro
CPU/Ram: asidm
Comment:

i am brand new to ASP VB and i am trying to make a login script, this one is basic but i cant figure out why this isnt working? any suggestions?

<html>
</head>
<body>
<% dim username %>
<% dim password %>
<form name="login" method="post" action="">

Username:<input type="text" name="username">
</p>

Password:<input type="text" name="password">
</p>
</form>
<% request.form("username") = username %>
<% request.form("password") = password %>
<% response.write(username) %>
<% response.write(password) %>
</body>
</html>


Report Offensive Message For Removal

Response Number 1
Name: FBI Agent
Date: July 22, 2004 at 21:00:13 Pacific
Subject: ASP simple question
Reply: (edit)

<% dim username as string %>
<% dim password as string %>


ok, i dont know ANYTHING about asp and i know very ltitle of VB, but i do know that when you dim somethign you have to specify it as something like an integer or a string

Password:<input type="text" name="password">
change the TYPE to password aswell

FBI_Agent

AIM: EliteAssassin187


Report Offensive Follow Up For Removal

Response Number 2
Name: SN
Date: July 22, 2004 at 21:59:19 Pacific
Subject: ASP simple question
Reply: (edit)

"but i do know that when you dim somethign you have to specify it as something like an integer or a string "
In many flavors of VB, yes. But this is vbscript, not VB. The dim statements are fine.

Matt-
First, you don't need to put every line in <% %> containers...Just use one set for groups of lines of code. Your mistake is actually pretty simple...
<% request.form("username") = username %>
<% request.form("password") = password %>
Should be
<%
username=request.form("username")
password=request.form("password")
%>

Altogether, this script should look something like this:
<html>
</head>
<body>
<form name="login" method="post" action="<%=request.servervariables("SCRIPT_NAME")%>">
Username:<input type="text" name="username">
< br>
Password:<input type="text" name="password">
< br>
<input type="submit" name="hit_submit" value="GO!">
</form>
<%
dim password, username

if (request("hit_submit") <> "") then
password=request("password")
username=request("username")
response.write(username & "< BR>" & password)
end if
%>
</body>
</html>

I'm not 100% on the request.servervariables("SCRIPT_NAME") part, but it's something like that. You can, of course, just type in the script name manually.

Luck
-SN


Report Offensive Follow Up For Removal

Response Number 3
Name: MarkM
Date: July 30, 2004 at 12:57:30 Pacific
Subject: ASP simple question
Reply: (edit)

One thing you should probably take into account.

You only really use request.form when you're receiving data posted from the last page.

I.E., your page with the username and password boxes would have a submit button on them, this button would automatically open another page in the same window which would receive the data posted from the form. This next page would then do the necessary script work on the username/password.

Cheers,
Mark


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: ASP simple question

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software