View Single Post
  #3 (permalink)  
Old 09-26-06, 01:09 PM
SuavyDoodle SuavyDoodle is offline
Newbie Coder
 
Join Date: Sep 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
thanks for your reply, the following is the edited script (edits in bold)




Code:
*/

//----------------------------------------------------------------
//  Usernames, Passwords & User Pages - These require configuration.
//----------------------------------------------------------------
var successpage = "index.htm";  // The page users go to after login, if they have no personal page.
var loginpage = "login.htm";  //Change this to the page the login panel is on.

var imgSubmit = "1";  //Change to the path to your login image,if you don't want the standard button, otherwise do not change.
var imgReset = "1";   //Change to the path to your reset image,if you don't want the standard button, otherwise do not change.

var users = new Array();

users[0] = new Array("Test","1111","");  // Change these two entries to valid logins.
users[1] = new Array("username2","password2","");          // Add addtional logins, straight after these, as
                                                           // required, followig the same format. Increment the 
											               // numbers in the square brackets, in new each one. Note:
											               // the 3rd parameter is the the page that user goes to
											               // after successful login. Ensure the paths are correct.
                                                           // Make this "" if user has no personal page.
//----------------------------------------------------------------
//  Login Functions
//----------------------------------------------------------------
function login(username,password){
 var member = null;
 var loggedin = 0;
 var members = users.length;
 for(x=0;x<members && !loggedin; x++){
 if((username==users[x][0])&&(password==users[x][1])){
    loggedin = 1;
    member = x;
	break; // User validated, terminate the for loop.
   }
 } 
 
 if(loggedin==1){
  if(users[member][2] != "") {
   successpage = users[member][2];
  }
  setCookie("login",1);
  if (top.location.href != location.href){
   location.href = successpage;           
  }else{
   top.location.href = successpage;  
  }
 }else{
  alert('Incorrect Login');
 }  
}

function logout() {
 deleteCookie("login");
 if (top.location.href != location.href){
  location.href = loginpage;           
 }else{
  top.location.href = loginpage;  
 }
}

//----------------------------------------------------------------
// Cookie Handler
//----------------------------------------------------------------
var ckTemp = document.cookie;

function setCookie(name, value) { 
 if (value != null && value != "")
  document.cookie=name + "=" + escape(value) + ";";
 ckTemp = document.cookie;
 }
 
function deleteCookie(name) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function getCookie(name) { 
 var index = ckTemp.indexOf(name + "=");
 if(index == -1) return null;
  index = ckTemp.indexOf("=", index) + 1;
 var endstr = ckTemp.indexOf(";", index);
 if (endstr == -1) endstr = ckTemp.length;
 return unescape(ckTemp.substring(index, endstr));
 }
  
function checkCookie() {
 var temp = getCookie("login");
 if(!temp==1) {
  alert('access denied'); 
  if(top.location.href != location.href){
   location.href = loginpage;           
  }else{
   top.location.href = loginpage;  
  }
 }
}

//----------------------------------------------------------------
// Login Panel
//----------------------------------------------------------------

function BuildPanel() {
document.write('<form name="logon"><table align="left" border="0"><tr><td align="right">');
document.write(' <i><b><font face="Palatino Linotype" size="4" color="#003399">Username</font></b></i></td>');document.write('<td><font face="Verdana"><input type="text" name="username" size="20"></font></td></tr>');
document.write('<tr><td align="right"><i><b><font face="Palatino Linotype" size="4" color="#003399">Password</font></b></i></td>');document.write('<td><font face="Verdana"><input type="password" name="password" size="20"></font></td></tr>');
if(imgSubmit == ""){
 document.write('<tr><td align="right" colspan="2"> <p><input type="button" value="Logon" name="Logon" onclick="login(username.value,password.value)">'); 
} else {
 document.write('<tr><td align="right" colspan="2"><input type="image" src="img/login_button.jpg" onclick="login(username.value,password.value);return false"/>');
}
if(imgReset == ""){
 document.write('<input type="reset" value="Reset" name="Reset">');
} else {
 document.write('<input type="image" src="img/clear_button.jpg" name="Reset" onclick="logon.reset();">');}
document.write('</p></td></tr></table></form>');
}
I've tried changing varimage from 1 to img source, but it doesn't make a difference. What's happening is if I follow all his directions, put the protection code on the pages, and then go back to login page to login, type in username and pass, click login, the page refreshes, and remains at login page.

Last edited by SuavyDoodle; 09-26-06 at 01:11 PM.
Reply With Quote