Free Web Hosting PHP/mySQL
GlobalWeb.com.ru Forum Index GlobalWeb.com.ru
Free Web Hosting :: Commercial Web Hosting :: PHP/mySQL :: CGI/Perl
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Basic Login Pages. (ASP)

 
Post new topic   Reply to topic    GlobalWeb.com.ru Forum Index -> ASP
Author Message
G-Bomb



Joined: 29 Feb 2004
Posts: 73

PostPosted: Tue Mar 02, 2004 5:31 pm    Post subject: Basic Login Pages. (ASP) Reply with quote

These codes will give you basic username/password capabilities. It's not fullproof, but it should do the job for a basic webpage.

First, create the following page called login.asp:

Code:
<%@ LANGUAGE="VBSCRIPT" %>

<%
If Request.QueryString("invalid") = "1" Then
   message = "Login Invalid"
Else
   message = ""
End If
%>

<HTML>
<HEAD>

<TITLE>Login</TITLE>
</HEAD>

<BODY>
<CENTER>
<H4>Login</H4>

<FORM ACTION="admin.asp" METHOD="post">
<TABLE ALIGN="center" CELLPADDING="0" CELLSPACING="0" STYLE="border-collapse: collapse" WIDTH="25%">
   <TR>
      <TH ALIGN="right">Username:&nbsp;&nbsp;</TH>
      <TD ALIGN="left"><INPUT TYPE="text" NAME="uname" WIDTH="40" size="20"></TD>
   </TR>
   
   <TR>
      <TH ALIGN="right">Password:&nbsp;&nbsp;</TH>
      <TD ALIGN="left"><INPUT TYPE="password" NAME="pword" WIDTH="10" size="20"></TD>
   </TR>
   
   <TR>
      <TD ALIGN="center" COLSPAN="2" HEIGHT="35" VALIGN="bottom">
         <INPUT TYPE="submit" VALUE=" Log In ">
      </TD>
   </TR>   
</TABLE>
</FORM>

<BR><BR><BR><BR><BR>
<H3>&nbsp;<%= message %>&nbsp;</H3>

</CENTER>
</BODY>
</HTML>
Back to top
View user's profile Send private message
G-Bomb



Joined: 29 Feb 2004
Posts: 73

PostPosted: Tue Mar 02, 2004 6:13 pm    Post subject: Reply with quote

The above login screen links a page called admin.asp, which will now be your password protected page. Create that page with the following code as your skeleton:

Code:
<%@ LANGUAGE="VBSCRIPT" %>

<HTML>
<HEAD>

<%
username = Request.Form("uname")
password = Request.Form("pword")

'   Usernames match up with passwords of the same array number; BE CAREFUL
usernames = array("Adam", "Bob", "Cindy", "Donald", "Eve")         '  Input all acceptable usernames here
passwords = array("adam1", "bob2", "cindy3", "donald4", "eve5")         '  Input all acceptable passwords here
   
valid = 0
For x = LBound(passwords) to UBound(passwords)
   If username = usernames(x) And password = passwords(x) Then
      valid = 1
   End If
Next
   
If valid = 0 Then
   Response.Redirect "login.asp?invalid=1"
End If
%>

<SCRIPT LANGUAGE="JavaScript"><!--
function forceSubmit() {
   document.frmCheckAdmin.submit();
}
// --></SCRIPT>
</HEAD>

<BODY Onunload="forceSubmit();">

<FORM NAME="frmCheckAdmin" ACTION="#" METHOD="post">
   <INPUT NAME="uname" TYPE="hidden" VALUE="<%= username %>">
   <INPUT NAME="pword" TYPE="hidden" VALUE="<%= password %>">
</FORM>

</BODY>
</HTML>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    GlobalWeb.com.ru Forum Index -> ASP All times are GMT
Page 1 of 1

 


Free Web Hosting, Commercial Web Hosting, PHP/mySQL Copyright © 2009
Free Scripts Directory | Free Software Downloads | Newsgroups Directory | Optel.net | Mirroraty | Cruised.net | Hardware Keylogger