Hello:

I am using a hardcoded user name and password to let users access a specific web page. It is coded in asp.

However, I now need to have users input their email addresses, but still use the hardcoded password to access the specific page.

I need to either have the email addresses sent via email to the admin, or send the email addresses to a simple db (which I must build) on an NT server.

Any ideas on how to do this?

Thanks in advance for your help.

matua105

Recommended Answers

All 2 Replies

First create simple login.asp page and copied belowe code

<!--#include file="includelogin.asp"-->
<html>

	<head>
	<meta http-equiv="Content-Language" content="en">
	<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
	<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
	<meta name="ProgId" content="FrontPage.Editor.Document">
	<title>You need to login</title>
	</head>

	<body>

	<%=sText%>	
	<%
	Dim sURL
	sURL = Request.ServerVariables("SCRIPT_NAME")
	If Request.ServerVariables("QUERY_STRING") <> "" Then
		'
		sURL = sURL & "?" & Request.ServerVariables("QUERY_STRING") 
	End If
	%>
    
	<form method="POST" action="<%=sURL%>">
	<input type="hidden" name="dologin" value="yes">
  	<table border="0" width="100%">
   	 <tr>
      <td>Loginname:</td>
      <td><input name="id" size="20"></td>
    </tr>
    <tr>
      <td>Password:</td>
      <td><input type="password" name="pwd" size="20"></td>
    </tr>
  </table>
  <p><input type="submit" value="Login" name="B1"></p>
	</form>

	</body>

	</html>
<%	
	Response.End
End If
%>


and now 

save this code below with this page name

includelogin.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Response.Buffer = True


Function ValidateLogin( sId, sPwd ) 
	' For you to validate ID and PASSWORD
	' Maybe against a database
	' Here we have hardcoded some OK id:s and passwords
	'
	ValidateLogin = False
	If sId = "anil_rash" AND sPwd="rashmi" Then
		ValidateLogin = True
	End If
	If sId = "user2" AND sPwd="pwd2" Then
		ValidateLogin = True
	End If
End Function


Dim sText, fBack

fBack = False
If Request.Form("dologin") = "yes" Then 
	'Try to login
	If ValidateLogin( Request.Form("id"),Request.Form("pwd") ) = True Then
		'It is OK!!!
		'We are logged in so lets go back to the file that included us  
		fBack = True
		Session("logonid") = Request.Form("id")
	Else
		sText = "Wrong password or user id"
	End If
Else
	'We are not trying to login...
	If Session("loginid") <> "" Then 
		'
		fBack = True
		'We are logged in so lets go back to the file that included us  
	Else
		sText = "Please login"
	End If
End If

If fBack = False Then
 %>

Thank Anil!

Regards,
matua105

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.