Solved

Have Username in field of another form

Posted on 2006-06-20
16
205 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ASP Classic - Load test 2 34
UTC (timezone) without using an API 16 28
Select2 jquery help 9 46
ASP Focus problem 3 30
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…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

747 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

13 Experts available now in Live!

Get 1:1 Help Now