Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

forms & username and passwords?!?

Status
Not open for further replies.

evismaniac

IS-IT--Management
Joined
Apr 21, 2002
Messages
14
Location
GB
Hi, can anyone help me with this. The situation is:

I have a website consisting of 4 webpages each containing a form.

The first 2 fields of each form are username and password. This is because when the form is submitted it needs to access a database with the username and password as entered by the user.

I would like to change this so that the user only has to enter their username and password once (on the homepage) and then the username and password fields on each of the 4 forms are automatically filled. The username and password fields would be hidden thus making the user only have to enter the remaining fields each time a form is submitted.

I'm a beginner with this sort of thing so any help would be much appreciated.....Thanks!
 
If you don't want to use session variables then

Login page
<html>
<body>
<form name=&quot;userInfo&quot; action=&quot;SecondPage.asp&quot; method=&quot;post&quot;>
<input type=&quot;text&quot; name=&quot;txtUserName&quot;>
<input type=&quot;password&quot; name=&quot;txtUserPWD&quot;>
<input type=submit value=&quot;Submit&quot;>
</form>
</body>
</html>

SecondPage.asp
<%
sUserName=request.form(&quot;txtUserName&quot;)
sPWD=request.form(&quot;txtUserPWD&quot;)
'Log into database and do query

%>
<html>
<body>
<form name=&quot;userInfo&quot; action=&quot;ThirdPage.asp&quot; method=&quot;post&quot;>
<input type=&quot;hidden&quot; name=&quot;txtUserName&quot; value=&quot;<%=sUserName%>&quot;>
<input type=&quot;hidden&quot; name=&quot;txtUserPWD&quot; value=&quot;<%=sPWD%>&quot;>
<input type=submit value=&quot;Submit&quot;>
</form>
</body>
</html>
THirdPage.asp etc
<%
sUserName=request.form(&quot;txtUserName&quot;)
sPWD=request.form(&quot;txtUserPWD&quot;)
'Log into database and do query

%>

<html>
<body>
<form name=&quot;userInfo&quot; action=&quot;FourthPage.asp&quot; method=&quot;post&quot;>
<input type=&quot;hidden&quot; name=&quot;txtUserName&quot; value=&quot;<%=sUserName%>&quot;>
<input type=&quot;hidden&quot; name=&quot;txtUserPWD&quot; value=&quot;<%=sPWD%>&quot;>
<input type=submit value=&quot;Submit&quot;>
</form>
</body>
</html>

If you want to used session variables.Session variables will have drawbacks if you have a large number of users.

Login page
<html>
<body>
<form name=&quot;userInfo&quot; action=&quot;SecondPage.asp&quot; method=&quot;post&quot;>
<input type=&quot;text&quot; name=&quot;txtUserName&quot;>
<input type=&quot;password&quot; name=&quot;txtUserPWD&quot;>
<input type=submit value=&quot;Submit&quot;>
</form>
</body>
</html>

SecondPage.asp
<%
session(&quot;username&quot;)=request.form(&quot;txtUserName&quot;)
session(&quot;PWD&quot;)=request.form(&quot;txtPWD&quot;)

'log into database
%>
<html>
<body>
Link to Third page
</body>
</html>
THirdPage.asp etc
<%
session(&quot;username&quot;)=request.form(&quot;txtUserName&quot;)
session(&quot;PWD&quot;)=request.form(&quot;txtPWD&quot;)

'log into database
%>

<html>
<body>
Link to other pages
</body>
</html>
 
Hi, thanks for the help. Ive tried the code but I cant see how the username and password typed in at the login page automatically enters into the username and password fields on the other pages....They still appear empty.

Also I'm using frames with a menu on the left which has the link to each page. Does this make a difference?

Forgive me if I'm completely wrong about this but I'm trying to learn myself.

Thanks again mate.

 
a frame setup would be different. Post the code so we can see what is going on.
 
Hi, ok the frameset code:

<html>
<head>
<title>Company Database Test</title>
<script language=&quot;JavaScript&quot;>
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName==&quot;Netscape&quot;)&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->
</script>
</head>
<frameset rows=&quot;19%,*&quot; cols=&quot;*&quot;>
<frame src=&quot;head.html&quot; noresize scrolling=&quot;no&quot; name=&quot;head&quot;>
<frameset cols=&quot;24%,*&quot; rows=&quot;*&quot;>
<frame src=&quot;menu.html&quot; noresize scrolling=&quot;no&quot; name=&quot;menu&quot;>
>
<frame src=&quot;home.html&quot; noresize scrolling=&quot;yes&quot; name=&quot;main&quot;>
</frameset>
</frameset>
<noframes>
</noframes>

--------------------------------------------------------
The homepage: (very basic, needs username & password form)

<html>
<head>
<LINK REL=&quot;stylesheet&quot; TYPE=&quot;text/css&quot; HREF=&quot;stylesheet.css&quot;>
<title>Company Database Test</title>
</head>

<body>Welcome to the Oracle Database Test website<p>
Please use the menu to the left access the Oracle database functions.<p>

</body>
</html>

--------------------------------------------------------
The add to database page (1 of 4 similar pages where I would like the username and password fields to be automatically completed depending on the initial login) BTW The form action link is not active at this time:

<!--add.html-->

<html><head>
<LINK REL=&quot;stylesheet&quot; TYPE=&quot;text/css&quot; HREF=&quot;stylesheet.css&quot;>
<title>Add to Oracle Database</title></head>
<h1>Add to Oracle Database<p></h1>
<body><hr>Please input your username and password along with the required data to add a record to the Department table</h1>
<form action=&quot; method=&quot;post&quot; name=form1>

<table>
<TR>
<TD></TD>
<TD>Username:</TD>
<TD><INPUT TYPE=&quot;text&quot; name=&quot;user&quot; SIZE=20 ></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD>Password:</TD>
<TD><INPUT TYPE=&quot;password&quot; name=&quot;pwd&quot; SIZE=20 ></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD>Department Number:</TD>
<TD><INPUT TYPE=&quot;text&quot; name=&quot;deptno&quot; SIZE=20 ></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD>Department Name:</TD>
<TD><INPUT TYPE=&quot;text&quot; name=&quot;deptname&quot; SIZE=20 ></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD>Location:</TD>
<TD><INPUT TYPE=&quot;text&quot; name=&quot;loc&quot; SIZE=20 ></TD>
<TD></TD>
</TR>
</table><br>

<input type=submit value=Submit onclick=
&quot;if (document.form1.user.value == '' || document.form1.pwd.value == '')
{
alert('Input all fields!')
return false
}&quot;
>
<input type=reset value=&quot;Clear&quot;>
</form>
</body>
</html>

-------------------------------------------------------
The head.html just has a logo etc, nothing related to the working of the site.

-------------------------------------------------------
The add.pl code:

#!/usr/local/bin/perl -w
#insert.pl

use DBI;
use CGI;

$rgt = new CGI;
$user = $rgt->param(&quot;user&quot;);
$pwd = $rgt->param(&quot;pwd&quot;);
$deptno = $rgt->param(&quot;deptno&quot;);
$deptname = $rgt->param(&quot;deptname&quot;);
$loc = $rgt->param(&quot;loc&quot;);

$dname =~ tr/a-z/A-Z/;
$loc =~ tr/a-z/A-Z/;

$ENV{ORACLE_HOME}=&quot;/u22/Oracle/9.0.1&quot;;
$ENV{ORACLE_SID}=&quot;shu9i&quot;;

$db = DBI->connect( &quot;DBI:Oracle(RaiseError=>1):shu9i&quot;, $user, $pwd) or die
&quot;Cannot connect to Oracle instance: $db->errstr\n&quot;;
$qry = &quot;INSERT into DEPT values (&quot; .$deptno. &quot;, '&quot; .$deptname. &quot;', '&quot; .$loc.
&quot;')&quot;;
$cursor = $db->prepare($qry) or die &quot;Cannot prepare cursor\n&quot;;
$cursor->execute or die &quot;Unable to execute SQL command\n&quot;;

$cursor->finish or die &quot;Cannot close cursor\n&quot;;
$db->disconnect or die &quot;Cannot disconnect from Oracle instance\n&quot;;

print &quot;Content-type: text/html\n\n&quot;;
print &quot;<HTML><HEAD><TITLE>Insert</TITLE></HEAD><body bgcolor=#CDCDCF><table align=center><hr>&quot;;
print &quot;<h3>Operation completed for user <font color=blue>&quot; . $user . &quot;</font>!</h3><hr><p>Department number <font color=blue> &quot; .$deptno. &quot; </font>, named <font color=blue> &quot; .$deptname. &quot;</font>, at location <font color=blue> &quot; .$loc.&quot; </font> has successfully been added to the DEPT table. Thank You&quot;;

print &quot;</table></body></HTML>&quot;;
exit(0);


-------------------------------------------------------
I have used Firewords for the menu.html so the code is fairly long. Basically it consists of 5 hyperlinks: Add.html, delete.html, view.html, update.html and home.html which are all displayed in the mainframe when clicked!


Hope this gives a clearer picture of what I have. Thanks again for any help!!!!!
 
Hi, any advice on this now ive posted the code.....? I would like to have this working by Sunday night if possible. Im trying different things but not having much luck!

Thanks for any more help.....
 
Sorry I can't help. I don't know Perl/CGI
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top