Solved

Have Username in field of another form

Posted on 2006-06-20
16
208 Views
Last Modified: 2012-08-13
I am just learning this stuff.. but I have a menu button that when clicked it shows it is a protected page and it takes you to a login.asp page.

then the user needs to enter their username and password... if it in the database it takes them to the page on the menu that they clicked.

On this page is a textbox that is titled name...

What I want is for the username to be automatically entered in the text box..

Example:

I click on the menu button "Availability"

It then take you to the login.asp page

User enters

Username: say "Steven"
Passwork: xxx

if that is in the database it takes you to the "Availability" page and

in the availability page I want the input field textbox to have "Steven" already in it.

Hope you understand..

Thank you
0
Comment
Question by:Shaft960
  • 8
  • 6
  • 2
16 Comments
 
LVL 14

Expert Comment

by:CyrexCore2k
ID: 16944306
On the login processing page write the following asp code

Session("Username") = Request.Form("username")

Then on the availibility page write

Response.Write "<input type=""text"" name=""username"" value=""" & Session("username") & """>"
0
 
LVL 22

Expert Comment

by:WMIF
ID: 16944327
on the page that processes your logon, you just need to set the username to a session variable.

session("username") = request.form("txtusername")


you can retrieve that 'username' from any other pages on your site while the user is browsing.  to set this to the text field:

<input type="text" id="txtuser" value="<%=session("username")%>">
0
 
LVL 22

Expert Comment

by:WMIF
ID: 16944337
ha! good thinking. :D
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:Shaft960
ID: 16944357
I dont know what page processes the login

do I put the code at the bottom of the html of the login page?
0
 
LVL 14

Expert Comment

by:CyrexCore2k
ID: 16944466
Show me the code where you verify the username and password and I'll show you where to put it.
0
 

Author Comment

by:Shaft960
ID: 16944474
This is the code that I have in the login.asp page.. where do I put the line...


<!--#include file="./base.inc"-->
<%
Dim iStatus, conn, str, sPage

if IsEmpty(Request.form("page")) Then
sPage = Request("page")
else
sPage = Request.form("page")
End If

str = ""

If NOT IsEmpty(Request.Form("User")) Then
Open_Conn(sPath)
iStatus = Check_Login(Request.Form("User"),Request.Form("Password"))

if iStatus > 0 Then

Session("login") = iStatus

Response.Redirect sPage

Else

Session("login") = -1

str = "Invalid Dash user/password code<BR> Try again "

End If

End If

%>

<html>

<head>

<title>DASH Login</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body bgcolor="#E3DFDF" text="#000000" topmargin=0 leftmargin=0 >

<p>&nbsp;</p><table width="900" border="0" cellspacing="0" cellpadding="0" height="560" align="center">

<tr>

<td valign="top" rowspan="2" width="228" bgcolor="#E3D9CD">

</td>

<td valign="top" height="497" width="672" bgcolor="#FFFFFF">

<table border=0 cellpadding=0 cellspacing=0 bgcolor="#CCCCCC" width="672">

<tr>

<td></td>

<td>&nbsp; </td>

<td>&nbsp; </td>

<td>&nbsp; </td>

<td>&nbsp; </td>

<td></td>

</tr>

</table>

<table width="672" border="0" cellspacing="0" cellpadding="0" height="360">

<tr>

<td rowspan="3" width="30"></td>

<td height="70" valign="bottom" colspan="3">

<p class="overview">

</td>

<td rowspan="3" width="30"></td>

</tr>

<tr>

<td height="17" valign="bottom" colspan="3"></td>

</tr>

<tr>

<td height="340" valign="top" width="290">

<p align="center"><b><font face="Tahoma" size="2">Please enter your

Username &amp; Password:</font><font face="Tahoma"> </font></b>

<p class="">

<FORM NAME="f" ACTION="./login.asp" METHOD=POST>

<INPUT TYPE=hidden NAME="page" VALUE="<% =sPage %>">

<TABLE BORDER=1 ALIGN=CENTER BGCOLOR=#FFFFFF><TR><TD class="">

<TABLE BORDER=1 ALIGN=CENTER BGCOLOR=#E4D7CB><TR><TD>

<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=0 ALIGN=CENTER BGCOLOR=#E3D9CD>

<TR BGCOLOR=#644632 BORDER=0>

<TH COLSPAN=2 VALIGN=TOP bgcolor="#669999">

<font color="#FFFF00"><span style="background-color: #0000FF">DASH Login Form
</span></font> </TH>

</TR>

<TR>

<TD VALIGN=TOP> <font color="#800000" face="Verdana, Arial, Helvetica, sans-serif" size="2">Username</font>

</TD>

<TD VALIGN=TOP>

<INPUT NAME="User" SIZE=15 MAXLENGTH=15 VALUE="<% =Request.Form("User") %>">

</TD>

</TR>

<TR>

<TD VALIGN=TOP> <font face="Verdana, Arial, Helvetica, sans-serif" color="#800000" size="2">Password</font>

</TD>

<TD ALIGN=LEFT VALIGN=TOP>

<INPUT TYPE=PASSWORD NAME="Password" SIZE=15 MAXLENGTH=15>

</TD>

</TR>

<TR> <TD COLSPAN=2 ALIGN=CENTER>

<INPUT TYPE=submit VALUE="Enter">

</TD>

</TR>

</TABLE>

</TD></TR></TABLE>

</TD></TR></TABLE>

</FORM>

<%

If str <> "" Then

Response.Write "<TABLE ALIGN=CENTER BORDER=0><TR><TD>" & vbCrLf

Response.Write "<FONT FACE=Verdana>" & str & "</FONT>" & vbCrLf

Response.Write "</TD></TR></TABLE>" & vbCrLf

End If

%>

<p class="">&nbsp;

<p class=""><br>

</td>

<td height="340" valign="top" width="32">

</td>

<td height="340" valign="top" width="290">

<p class=""><br>

</p>

<p>&nbsp;</td>

</tr>

</table>

</td>

</tr>

<tr>

<td valign="bottom" width="672" bgcolor="#FFFFFF">

</td>

</tr>

</table>

</body>

</html>

<%

Function Check_Login(sUser, sPass)

Dim rs, sql

sql = "SELECT * FROM Results WHERE name ='" & sUser & "' AND password='" & sPass & "' "

Set rs = Server.CreateObject("ADODB.RecordSet")

rs.open sql, conn, 1, 1

If Rs.EOF Then

Check_Login = -1

Else

' rs.Fields("dDtConn").Value = Now()

' If rs.Fields("iCount").Value > 0 Then

' rs.Fields("iCount").Value = rs.Fields("iCount") + 1

' Else

' rs.Fields("iCount").Value = 1

' End If

' rs.Update

Check_Login = CInt(rs.Fields("id"))

End If

rs.close

End Function

Function Open_Conn(sBase)

Set conn = Server.CreateObject("ADODB.Connection")

conn.open sBase,"",""

End Function

%>
0
 

Author Comment

by:Shaft960
ID: 16944483
I think I have the username  as user..

0
 
LVL 14

Expert Comment

by:CyrexCore2k
ID: 16944523
If NOT IsEmpty(Request.Form("User")) Then
Open_Conn(sPath)
iStatus = Check_Login(Request.Form("User"),Request.Form("Password"))

if iStatus > 0 Then

Session("login") = iStatus
Session("Username") = Request.Form("User") '<-------------------------------------- I put it right here
Response.Redirect sPage

Else

Session("login") = -1

str = "Invalid Dash user/password code<BR> Try again "

End If

End If
0
 
LVL 14

Expert Comment

by:CyrexCore2k
ID: 16944527
Then whenever you want to put their username somewhere just use

Session("username")

You can make sure it worked by putting

Response.Write Session("username")

in one of your pages.
0
 

Author Comment

by:Shaft960
ID: 16944844
I am having a problem getting it to work.. It is coming up in the next page but the ....

Here is the line that I need to put the info into..


<!--webbot bot="Validation" s-data-type="String" b-value-required="TRUE" i-minimum-length="2" --><input name="Name" size="35" tabindex="1"></font></p>

HOW do I add the username to this line as the initial value?

Thanks
0
 
LVL 14

Accepted Solution

by:
CyrexCore2k earned 500 total points
ID: 16945090

<!--webbot bot="Validation" s-data-type="String" b-value-required="TRUE" i-minimum-length="2" --><input name="Name" size="35" value="<%=session("username")%>" tabindex="1"></font></p>
0
 

Author Comment

by:Shaft960
ID: 16945204
Thank you ... but form some reason the submit isn't working now.. could it be due to the line of code;

Session("Username") = Request.Form("User")

which was placed in the login.asp?
0
 

Author Comment

by:Shaft960
ID: 16945219
Points have been raised to 500
0
 
LVL 14

Expert Comment

by:CyrexCore2k
ID: 16945307
How exactly is it not working?
0
 

Author Comment

by:Shaft960
ID: 16945340
Well,  the username comes into the input area.. but there are other inputs.. when you put those in and then push submit. it use to take you to a confirmation page.. not it just clears all the data except the username and does nothing..
0
 

Author Comment

by:Shaft960
ID: 16945666
I changed a page name that was what was the problem.. now I cant find the confirmation page... Thanks for your help
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Classic ASP - problem with MS SQL Select Query? 10 60
Using Classic ASP inside HTML pages 2 62
wordpress display sub menu only when click 12 49
Adding Row and Cell on a table 14 25
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question