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!

asp and dreamweaver

Status
Not open for further replies.

samme42

Programmer
Joined
Sep 11, 2003
Messages
3
Location
US
An outside company developed a safety training program in dreamweaver. I've been asked to hardcode a username and password that is issued to the user at the end of a training module. This username and password allows them to enter the next training module. They do not want to use a database, just hardcode it into the page. So, if they type the username and password incorrectly into the textboxes, they receive a message and the chance to try again. If they type it in correctly, then they can continue. Possible? Please help! I am very new to Dreamweaver and .asp. Thank you in advance!!
 
Basically you just need to create a simple form that has an entry for username and password and subimts to a processing page.
The processing page basically just needs to check the two submitted form values against two hardcoded values. If the username/password pair is not valid then redirect back to the first page, otherwise redirect to the next section.

I can't describe how to do this in Dreamweaver, as I haven't so much as looked at that app in years. Hopefully the info supplied will be enough to point you in the direction you need,

-T

barcode_1.gif
 
here is a simple asp login form that if you enter the username and password it will direct you to a page called main.asp
save this page as index.asp
if you get it wrong an error will be displayed

its up to you to learn about getting info from a forms controls and about "posting"

userid = testuser
password = testpw

Code:
<%
If Request.Form("submit") <> "" Then
	validpwd = False

	' Setup variables
	userid = Request.Form("userid")
	passwd = Request.Form("passwd")
	If ((UCase("testuser") = UCase(userid)) And (UCase("testpw") = UCase(passwd))) Then
		validpwd = True
	End If
	conn.Close
	Set conn = Nothing
	End If
	If validpwd Then
	Response.Redirect "main.asp"
%>
<html>
<head>
<title></title>
</head>

<body>
<table border="0" cellspacing="0" cellpadding="2" align="center">
	<tr>
		<td></td>
	</tr>
</table>
<% If Not validpwd Then %>
<p align="center"><font color="#FF0000">Incorrect user ID or password</font></p>
<% End If %>
<form action="login.asp" method="post">
<table border="0" cellspacing="0" cellpadding="4" align="center">
	<tr>
		<td>User Name</td>
		<td><input type="text" name="userid" size="20" value=""></td>
	</tr>
	<tr>
		<td>Password</td>
		<td><input type="password" name="passwd" size="20"></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>	
	<tr>
		<td colspan="2" align="center"><input type="submit" name="submit" value="Login"></td>
	</tr>
</table>
</form>
</body>
</html>
 
sorry couple of errors try this...

also save this page as login.asp NOT index.asp
on your index.asp or default.asp page it should have
response.redirect "login.asp"

Code:
<!--#include file="db.asp"-->
<%
If Request.Form("submit") <> "" Then
	validpwd = False

	' Setup variables
	userid = Request.Form("userid")
	passwd = Request.Form("passwd")
	If ((UCase("testuser") = UCase(userid)) And (UCase("testpw") = UCase(passwd))) Then
		validpwd = True
	End if
	If validpwd Then
	Response.Redirect "main.asp"
	End If
	Else
	validpwd = True
	End If
%>
<html>
<head>
<title></title>
</head>

<body>
<table border="0" cellspacing="0" cellpadding="2" align="center">
	<tr>
		<td></td>
	</tr>
</table>
<% If Not validpwd Then %>
<p align="center"><font color="#FF0000">Incorrect user ID or password</font></p>
<% End if%>
<form action="login.asp" method="post">
<table border="0" cellspacing="0" cellpadding="4" align="center">
	<tr>
		<td>User Name</td>
		<td><input type="text" name="userid" size="20" value=""></td>
	</tr>
	<tr>
		<td>Password</td>
		<td><input type="password" name="passwd" size="20"></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>	
	<tr>
		<td colspan="2" align="center"><input type="submit" name="submit" value="Login"></td>
	</tr>
</table>
</form>
<br>
</body>
</html>
 
sorry couple of errors try this...

also save this page as login.asp NOT index.asp
on your index.asp or default.asp page it should have
response.redirect "login.asp"

Code:
<!--#include file="db.asp"-->
<%
If Request.Form("submit") <> "" Then
	validpwd = False

	' Setup variables
	userid = Request.Form("userid")
	passwd = Request.Form("passwd")
	If ((UCase("testuser") = UCase(userid)) And (UCase("testpw") = UCase(passwd))) Then
		validpwd = True
	End if
	If validpwd Then
	Response.Redirect "main.asp"
	End If
	Else
	validpwd = True
	End If
%>
<html>
<head>
<title></title>
</head>

<body>
<table border="0" cellspacing="0" cellpadding="2" align="center">
	<tr>
		<td></td>
	</tr>
</table>
<% If Not validpwd Then %>
<p align="center"><font color="#FF0000">Incorrect user ID or password</font></p>
<% End if%>
<form action="login.asp" method="post">
<table border="0" cellspacing="0" cellpadding="4" align="center">
	<tr>
		<td>User Name</td>
		<td><input type="text" name="userid" size="20" value=""></td>
	</tr>
	<tr>
		<td>Password</td>
		<td><input type="password" name="passwd" size="20"></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>	
	<tr>
		<td colspan="2" align="center"><input type="submit" name="submit" value="Login"></td>
	</tr>
</table>
</form>
<br>
</body>
</html>
 
Thanks, mjonson! I'm going to give your code a try! But, I have to put it within the existing login pages. All of the login pages are created - login page copy1.asp, login page copy2.asp and so on. In the end of a module, the user is given a password (i checked again and no username) to enter on the login page. I am very new to this and am trying to sort threw the existing code and put your code to check for the correct password in the proper place! I included the existing code for you to view. Where can I go to gain an understanding of this code?? Thank you so much for your assistance!!

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!-- TemplateBeginEditable name="doctitle" -->
<title>LoginPage1</title>
<!-- TemplateEndEditable --><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(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);

function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args+".location='"+args[i+1]+"'");
}

function MM_timelinePlay(tmLnName, myID) { //v1.2
//Copyright 1997, 2000 Macromedia, Inc. All rights reserved.
var i,j,tmLn,props,keyFrm,sprite,numKeyFr,firstKeyFr,propNum,theObj,firstTime=false;
if (document.MM_Time == null) MM_initTimelines(); //if *very* 1st time
tmLn = document.MM_Time[tmLnName];
if (myID == null) { myID = ++tmLn.ID; firstTime=true;}//if new call, incr ID
if (myID == tmLn.ID) { //if Im newest
setTimeout('MM_timelinePlay("'+tmLnName+'",'+myID+')',tmLn.delay);
fNew = ++tmLn.curFrame;
for (i=0; i<tmLn.length; i++) {
sprite = tmLn;
if (sprite.charAt(0) == 's') {
if (sprite.obj) {
numKeyFr = sprite.keyFrames.length; firstKeyFr = sprite.keyFrames[0];
if (fNew >= firstKeyFr && fNew <= sprite.keyFrames[numKeyFr-1]) {//in range
keyFrm=1;
for (j=0; j<sprite.values.length; j++) {
props = sprite.values[j];
if (numKeyFr != props.length) {
if (props.prop2 == null) sprite.obj[props.prop] = props[fNew-firstKeyFr];
else sprite.obj[props.prop2][props.prop] = props[fNew-firstKeyFr];
} else {
while (keyFrm<numKeyFr && fNew>=sprite.keyFrames[keyFrm]) keyFrm++;
if (firstTime || fNew==sprite.keyFrames[keyFrm-1]) {
if (props.prop2 == null) sprite.obj[props.prop] = props[keyFrm-1];
else sprite.obj[props.prop2][props.prop] = props[keyFrm-1];
} } } } }
} else if (sprite.charAt(0)=='b' && fNew == sprite.frame) eval(sprite.value);
if (fNew > tmLn.lastFrame) tmLn.ID = 0;
} }
}

function MM_initTimelines() { //v4.0
//MM_initTimelines() Copyright 1997 Macromedia, Inc. All rights reserved.
var ns = navigator.appName == "Netscape";
var ns4 = (ns && parseInt(navigator.appVersion) == 4);
var ns5 = (ns && parseInt(navigator.appVersion) > 4);
document.MM_Time = new Array(1);
document.MM_Time[0] = new Array(2);
document.MM_Time["Timeline1"] = document.MM_Time[0];
document.MM_Time[0].MM_Name = "Timeline1";
document.MM_Time[0].fps = 15;
document.MM_Time[0][0] = new String("behavior");
document.MM_Time[0][0].frame = 445;
document.MM_Time[0][0].value = "MM_goToURL('parent','page2.html')";
document.MM_Time[0][1] = new String("behavior");
document.MM_Time[0][1].frame = 1;
document.MM_Time[0][1].value = "MM_timelinePlay('Timeline1')";
document.MM_Time[0].lastFrame = 445;
for (i=0; i<document.MM_Time.length; i++) {
document.MM_Time.ID = null;
document.MM_Time.curFrame = 0;
document.MM_Time.delay = 1000/document.MM_Time.fps;
}
}
//-->
</script>
<!-- TemplateBeginEditable name="head" --><!-- TemplateEndEditable -->
</head>

<body onLoad="MM_timelinePlay('Timeline1')">
<div id="tableBackground" style="position:absolute; left:8px; top:8px; width:850px; height:638px; z-index:5; background-color: #000000; layer-background-color: #000000; border: 1px none #000000;">
<div id="Layer4" style="position:absolute; left:39px; top:546px; width:29px; height:33px; z-index:8">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=" width="18" height="18">
<param name="movie" value="LogIn.swf">
<param name="quality" value="high">
<param name="LOOP" value="false">
<param name="BGCOLOR" value="#4F4F4F">
<embed src="LogIn.swf" width="18" height="18" loop="false" quality="high" pluginspage=" type="application/x-shockwave-flash" bgcolor="#4F4F4F"></embed>
</object>
</div>
<table width="850" height="683" border="2" cellpadding="1" cellspacing="2" bordercolor="#FFFFFF" background="file:///Power%20Broker/BOLLINGER/Sec%201%20-%20Welcome/bollNHOSec.1-LB/Backgrounds-Used/BkgdLtBlue.jpg" bgcolor="#666666">
<tr>
<td height="667" colspan="8" bordercolor="#000000" background="Images/Boll of sign art pedgblu.jpg" bgcolor="#FFFFFF"><div align="left">
<p align="center">&nbsp;</p>
<p align="center"><font color="#FFFFFF" size="7" face="Times New Roman, Times, serif"><strong></strong></font></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<h1 align="center">&nbsp;</h1>
<div id="Layer2" style="position:absolute; width:506px; height:72px; z-index:7; left: 176px; top: 13px;">
<div align="center"><font color="#999999" size="7" face="Arial, Helvetica, sans-serif"><strong><img src="Images/Logo3embossed.png" width="300" height="125"></strong></font></div>
</div>
<h1 align="center"><font color="#999999" size="7" face="Arial, Helvetica, sans-serif"></font></h1>
</div></td>
</tr>
</table>
</div>
<div id="forwardLink" style="position:absolute; left:792px; top:632px; width:44px; height:38px; z-index:1;"><img src="file:///Power%20Broker/BOLLINGER/Sec%201%20-%20Welcome/bollNHOSec.1-LB/navigate/forwardBtnRed.jpg" width="44" height="38"></div>
<div id="Layer1" style="position:absolute; left:219px; top:216px; width:428px; height:120px; z-index:6">
<form name="form2" method="post" action="">
<table width="100%" border="1">
<tr>
<td width="27%"><strong><font color="#FFFFFF" size="4">Password</font></strong></td>
<td width="73%"><input name="password" type="password" id="password2">
</td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input name="Submit" type="submit" onClick="MM_goToURL('parent','bollCBTSec.3/home.html');return document.MM_returnValue" value="Log In">
</div>
</td>
</tr>
</table>
</form>
</div>
<div id="Layer3" style="position:absolute; left:186px; top:167px; width:506px; height:27px; z-index:7">
<h3 align="center"><strong><font color="#FFFFFF">Please
enter the password given at the end of the last section.</font></strong></h3>
</div>
<p><a href="file:///Power%20Broker/BOLLINGER/Sec%201%20-%20Welcome/bollNHOSec.1-LB/mirrorImages.html" target="_blank">mirrorImages.html</a><a href="file:///Power%20Broker/BOLLINGER/Sec%201%20-%20Welcome/bollNHOSec.1-LB/mirrorImages.html">mirrorImages.html</a>
Bollinger Shipyards</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top