110mb.com Forum
News: Currently none. But refer to this news before you post an error, maybe it's already being fixed Wink
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 06, 2008, 12:32:38 AM


Login with username, password and session length


Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: (WANTED) Login Script  (Read 1101 times)
lestai99
Member
*
Offline Offline

Posts: 7


WWW
« on: July 25, 2008, 05:08:25 AM »

I need someone to create a login script so that only certain people can access some pages of my website.
Logged
manicgames
Visual Basic Programmer!
Official 110mb Guru
********
Online Online

Posts: 6046


Ubuntu Kicks @$$!


WWW
« Reply #1 on: July 25, 2008, 07:24:50 AM »

And are you expecting this free or willing to pay?  undecided

Oh, and the easiest way to password protect pages is to use .htaccess which is VERY easy to use. You can pay a small fee to get it.
Logged

Coca-Cola
Active Member
**
Offline Offline

Posts: 73


« Reply #2 on: July 25, 2008, 06:43:45 PM »

I need someone to create a login script so that only certain people can access some pages of my website.

There's ALOT out there. Why don't you just search for one and use that?
Logged
general vegitable
ⓖⓔⓝⓔⓡⓐⓛ ⓥⓔⓖⓘⓣⓐⓑⓛⓔ
Loyal 110MB Member
*******
Offline Offline

Posts: 3543


please ask (by pm duh!) before you yim me


WWW
« Reply #3 on: July 25, 2008, 06:48:42 PM »

i think that aldo made one recently, or you could try mop
Logged



woot, i have a 110mb status system see => http://general-vegitable.110mb.com/110status
lestai99
Member
*
Offline Offline

Posts: 7


WWW
« Reply #4 on: July 26, 2008, 03:29:42 AM »

I've found one online, it looks good, but part of it doesn't work. The login part seems to work, but I can still go directly to the pages that I want protected without logging in (I tried that before I tried the page that I use to log in). Can anyone tell me how to fix it?

This is the main part:

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

var imgSubmit = ""; //Change to the path to your login image,if you don't want the standard button, otherwise do not change.
var imgReset = "";  //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("user","pass","http://lestai99.110mb.com/index.php"); // Change these two entries to valid logins.
users[1] = new Array("username2","password2","member2.html"); // 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;
   }
 }
 
 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('access denied'); // Insert a fail message.
 } 
}

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'); // Rensert a fail message.
  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('<small><font face="Verdana">Username:</font></small></td>');
document.write('<td><small><font face="Verdana"><input type="text" name="username" size="20"></font></small></td></tr>');
document.write('<tr><td align="right"><small><font face="Verdana">Password:</font></small></td>');
document.write('<td><small><font face="Verdana"><input type="password" name="password" size="20"></font></small></td></tr>');
if(imgSubmit == ""){
 document.write('<tr><td align="center" colspan="2"><p><input type="button" value="Logon" name="Logon" onclick="login(username.value,password.value)">');
} else {
 document.write('<tr><td align="center" colspan="2"><p><input type="image" src="'+imgSubmit+'" name="Logon" onclick="login(username.value,password.value)">');
}
if(imgReset == ""){
 document.write('<input type="reset" value="Reset" name="Reset">');
} else {
 document.write('<input type="image" src="'+imgReset+'" name="Reset" onclick="logon.reset();">');
}
document.write('</p></td></tr></table></form>');
}

and this is what I'm supposed to put at the top of the pages I want to be protected:

Code:
<script src="scripts/login.js"></script>
 <script language="JavaScript">
  checkCookie();
 </script>
« Last Edit: July 26, 2008, 03:52:52 AM by lestai99 » Logged
fiate2000
Authority Member
****
Offline Offline

Posts: 515


WWW
« Reply #5 on: August 11, 2008, 05:51:42 PM »

I need someone to create a login script so that only certain people can access some pages of my website.
Checkout the my coding page - http://fiate2000.110mb.com/work.php. it contains a basic login script.
Logged

baelinc
Member
*
Offline Offline

Posts: 12


WWW
« Reply #6 on: August 11, 2008, 11:20:13 PM »

What you could do is use this script on your index page so that the first thing the people see is a box for a user name and password, and once that is accepted they will get your first page.

Quote
<?php



// Define your username and password

$username = "someuser";

$password = "somepassword";



if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {



?>



<h1>Login</h1>



<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

    <p><label for="txtUsername">Username:</label>

    <br /><input type="text" title="Enter your Username" name="txtUsername" /></p>



    <p><label for="txtpassword">Password:</label>

    <br /><input type="password" title="Enter your password" name="txtPassword" /></p>



    <p><input type="submit" name="Submit" value="Login" /></p>



</form>



<?php



}

else {



?>



<p>This is the protected page. Your private content goes here.</p>



<?php



}



?>
Logged
fiate2000
Authority Member
****
Offline Offline

Posts: 515


WWW
« Reply #7 on: September 07, 2008, 07:25:33 PM »

I need someone to create a login script so that only certain people can access some pages of my website.

or you can use htaccess to password protect folders
Logged

physicshelp4u
Hyper-Active Member
***
Online Online

Posts: 155



WWW
« Reply #8 on: September 08, 2008, 12:56:47 AM »

the easiest way is to protect directories from control panel with certain user names and passwords though it is not very recommended....
Logged

general vegitable
ⓖⓔⓝⓔⓡⓐⓛ ⓥⓔⓖⓘⓣⓐⓑⓛⓔ
Loyal 110MB Member
*******
Offline Offline

Posts: 3543


please ask (by pm duh!) before you yim me


WWW
« Reply #9 on: September 08, 2008, 01:15:55 AM »

i use something simalar to the above one
Code:
<html>
<head>
<title>admin index</title>
</head>
<body>
<?php



//username and password mod this bit

$username = "username";

$password = "password";

//now DO NOT mod this bit

if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {



?>




<h1>Login (changeable)</h1>

<a href=path/to.home>return to site</a>

<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

    <p><label for="txtUsername">Username:</label>

    <br /><input type="text" title="Enter your Username" name="txtUsername" /></p>



    <p><label for="txtpassword">Password:</label>

    <br /><input type="password" title="Enter your password" name="txtPassword" /></p>



    <p><input type="submit" name="Submit" value="Login" /></p>



</form>



<?php
//leave this alone


}

else {



?>




<h1>protected page</h1>
<p>put what you want to protect here</p>



<?php
//leave alone, this bit ends the code


}



?>

</body>
</html>
thats for the entire file, you can mod the html bits but not the php bits.
Logged



woot, i have a 110mb status system see => http://general-vegitable.110mb.com/110status
pimpinproductions
im a g the 7th letter of the alphabet
Active Member
**
Offline Offline

Posts: 57



WWW
« Reply #10 on: September 19, 2008, 01:24:40 PM »

and there is an error in that code.


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

var imgSubmit = ""; //Change to the path to your login image,if you don't want the standard button, otherwise do not change.
var imgReset = "";  //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("user","pass","http://lestai99.110mb.com/index.php"); // Change these two entries to valid logins.
users[1] = new Array("username2","password2","member2.html"); // Add addtional logins, straight after these, as
                                                                // required, following the same format. Increment the


its following not followig

Smiley
Logged

robleyd
Loyal 110MB Member
*******
Online Online

Posts: 4551

Ask before you PM


« Reply #11 on: September 19, 2008, 01:33:08 PM »

I don't think a typo in a comment is going to make much difference to the way the code works.
Logged

News Flash:  Microsoft acquires Electrolux, makes extensive design revisions.  Finally releases a product that doesn't suck.

No electrons were harmed in the creation, transmission or reading of this post. However, many were excited and some may well have enjoyed the experience.

The difference between a bagpipe and a trampoline is that you have to take your shoes off to jump on a trampoline.
general vegitable
ⓖⓔⓝⓔⓡⓐⓛ ⓥⓔⓖⓘⓣⓐⓑⓛⓔ
Loyal 110MB Member
*******
Offline Offline

Posts: 3543


please ask (by pm duh!) before you yim me


WWW
« Reply #12 on: September 20, 2008, 01:34:37 AM »

the script that i use is basicly an admin login, one user only. its basicly the same as baelincs one, but slightly altered
Logged



woot, i have a 110mb status system see => http://general-vegitable.110mb.com/110status
Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  

  Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC

Theme by Dilber MC | Using SEO4SMF Mod

All content on this forum (especially posts) is copyright property of 110mb & the member
who wrote the post. So if you wish to steal anyone's post on this forum, you'll wish you
were dead because our lawyers will sue your ass!