Solved

Have Username in field of another form

Posted on 2006-06-20
16
206 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 - cannot get to correct path 17 67
Auto Submit on dropdown box 14 52
Bypass cross origin issues on development site 3 63
wordpress display sub menu only when click 12 23
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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 is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now