Wrox Programmer Forums
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 15th, 2005, 01:21 PM
Friend of Wrox
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default login script

   Does anyone have any code that will create a login on a page and save the username and password somewhere for later use like a document or something. And if possible can it be in the form of a *.js file but if you cant then dont worry!

Apocolypse2005, I'm a programmer - of sorts.
Old June 24th, 2005, 01:30 AM
Registered User
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen

Here it is..
----------------------- file 1 --------
<%@ language = VBScript %>
<% Option Explicit %>

dim objRS
set objRS = server.createobject("ADODB.Recordset")

if request.form("lname") = "" then
    response.redirect("mainlogin.asp?etext=Missing Parameters.")
end if

session("empid") = mid(request.form("lname"),2)
session.timeout = 120

objRS.open "select * from EmpMaster where EmpID = " & session("empid") ,objConn

if objRS.EOF then
    response.redirect("mainlogin.asp?etext=Login name not found.")
end if

if request.form("pass") = objRS("Password") then

    'Writing cookies for EmpID, Fname, Lname and Roll, (phone no for leave page), teamid (for timesheet)
    'If want to remember ID
    if request.form("rememberme") then
        response.cookies("Lid") = "u" & objRS("empid")
        response.cookies("Lid").expires = date + 7
    end if
    response.cookies("teamid") = objRS("empteam")
    response.cookies("empfname") = objRS("empfname")
    response.cookies("emplname") = objRS("emplname")
    response.cookies("emproll") = objRS("emproll")
    response.cookies("mobilno") = objRS("EmpMobNo")

    'Redirect to mainpage
    response.redirect("mainlogin.asp?etext=Wrong Password. Please check for CAPS LOCK.")
end if

set objRS = Nothing

set objConn = Nothing
------------------- -------------------
------------------- file 2 -----------
<% Option Explicit %>
<title>Time Sheet Management System</title>
<script type="text/javascript">
function setfocus()
var logID = ReadCookie("Lid");
    if (logID != "")
        document.getElementById("Lname").value = logID ;

function ReadCookie(cookieName)
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return "";
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length;
 return unescape(theCookie.substring(ind+cookieName.length +1,ind1));
<body onload="setfocus()">
<img src="wnslogo.jpg"><br><br>
<p align="center"><br><br>

<b>Time Sheet Management System</b>

<% response.write request.querystring("etext") %>

<form method="POST" name="login" action="Login.asp">
<table cellspacing="3" cellpadding="7" bgcolor="#996633" >
<tr><td>Login</td><td><input type = "text" name = "Lname" ></td></tr>
<tr><td>Password</td><td><input type = "password" name = "Pass"></td></tr>
<tr ><td colspan="2" align="center"><input type="checkbox" name="rememberme" value="1">Remeber my login on this computer.</td></tr>
<tr><td colspan = "2" align = "center" ><input type = "submit" value = "Enter" ></td></tr>
<p align="center"><br><br><br><br><br><br><br><br>
&copy;WNS Global Services (P) Ltd.

Old June 24th, 2005, 02:44 AM
Friend of Wrox
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts

Thanks alot for that!! amazing
Old June 24th, 2005, 04:07 PM
Friend of Wrox
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts

How do i use this what do i call file no.1? whats the file extension aswell? and i expect the second file is html!
thanks alot

Similar Threads
Thread Thread Starter Forum Replies Last Post
having a problem with login script dbwieler PHP Databases 1 November 14th, 2007 02:12 AM
login script: user can't hit "return" for login dmerrill Java Basics 13 July 14th, 2006 07:25 PM
login script jstewie Javascript How-To 1 July 13th, 2005 12:52 PM
login script problem hosefo81 PHP How-To 9 August 20th, 2004 11:28 AM
Login Script natmaster PHP How-To 10 June 19th, 2003 03:50 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.