Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
login script without mysql
Old 12-21-2007, 04:59 PM login script without mysql
Junior Talker

Posts: 2
Name: Jay
Trades: 0
I was wondering if there were any ways to do a login system without using a mysql database or table.

if there is, can someone post one up?
Jay77710 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-21-2007, 05:30 PM Re: login script without mysql
JamieLewis's Avatar
Pretty Much a Big Deal...

Latest Blog Post:
Gooie
Posts: 385
Name: Jamie Lewis
Location: UK
Trades: 0
There is a very simple way in which you check the username and password agains a hardcoded value

Code:
if($username == "User" & $password == "Pass"){
//set sessions etc here
}

Other than that, there isn't really any other secure way to do so.

Jamie
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
JamieLewis is offline
Reply With Quote
View Public Profile Visit JamieLewis's homepage!
 
Old 12-21-2007, 05:32 PM Re: login script without mysql
Junior Talker

Posts: 2
Name: Jay
Trades: 0
it doesn't really need to be secure... I just need a login system without using mysql that doesn't look like crap
Jay77710 is offline
Reply With Quote
View Public Profile
 
Old 12-21-2007, 05:36 PM Re: login script without mysql
JamieLewis's Avatar
Pretty Much a Big Deal...

Latest Blog Post:
Gooie
Posts: 385
Name: Jamie Lewis
Location: UK
Trades: 0
um...looks have very little to do with authentication systems. Generally you have a form, then a processing page, then a landing page.

The form is basic HTML, the processing page checks the sent values against authorised values (using either sql, flat files or hardcoded methods) and then sets a session saying the user is logged in. The user is then sent to the landing page and any other processing can be done there (extra widgets etc. can be added to the markup)

Jamie
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
JamieLewis is offline
Reply With Quote
View Public Profile Visit JamieLewis's homepage!
 
Old 12-23-2007, 01:35 PM Re: login script without mysql
J0ker's Avatar
Skilled Talker

Posts: 61
Trades: 0
You could have it used the fopen command to open up some file and put in and look for the username and password of users, but of course its extremely insecure.
__________________

Please login or register to view this content. Registration is FREE
- Free Gaming Forum/Arcade

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
J0ker is offline
Reply With Quote
View Public Profile
 
Old 12-24-2007, 12:29 PM Re: login script without mysql
Novice Talker

Posts: 8
Name: Chris
Location: Swindon
Trades: 0
As far as I'm aware, there wouldn't be a very good way of doing this at all.

THe MySQL DB would store all the username data ect, although, you can do this using a .txt file, but if someone realises that you don't have a MySQL database for this, its easy enough to figure out you're using a .txt file, which they can then open in their browser and get all the usernames and passwors ect.


The only otherway I can think of is using .htaaccess, but this will open a popup box (like when a directory is password protected but requires the admin to make the username).
Lorem-Ipsum is offline
Reply With Quote
View Public Profile
 
Old 12-24-2007, 07:13 PM Re: login script without mysql
Novice Talker

Posts: 13
Name: hach22
Trades: 0
login.php
PHP Code:
<?php

/**
 * @Author H22CREATIONS
 * @Copyright 2007
 */

session_start();

function 
logout_link(){//return LogoutLink or nothing
    
if ($_SESSION[logged])
        return 
'<a href="login.php?logout=yes">Logout</a>';
}


function 
login(){//return LOGINFORM(HTML) , FALSE , 1 or 2
if (!$_SESSION[logged]){//if not logged:
    
if (empty($_POST)){//if nothing posted return login form
        
return '
        <form method="post" action="login.php">
        Username: <input type="text" name="username" /><br />
        Password<input type="password" name="password" /><br />
        <input type=submit name=submit />
        </form>'
;
    }
// END if
    
else{//If something posted 
        
$handle=fopen('bd.php','rb');
        
fseek($handle150);//Ignore first 2 Line
        
while (!feof($handle)){//STOP When (EOF reached)
            
list($u,$p)=explode("\t",fgets($handle));
            
$p=str_replace("\r\n","",$p);
            if ((
$_POST[username]===$u) && ($_POST[password]===$p)){
                
fclose($handle);
                
$_SESSION[logged]=TRUE;
                return 
1;//USERNAME AND PASSWORD TRUE
            
}//END if
        
}//END While
    
if(!$_SESSION[logged]){
            
fclose($handle);
            return 
FALSE;//Error False username or password
        
}//END if
    
}
}
//if logged
else return 2;//Already logged
}

if (
$_GET[logout]){
    
$_SESSION[logged]=FALSE;//LOGOUT
}// END if

//SOME TESTS
    
echo'<pre>';
    
var_dump (login());
    echo 
logout_link();
bd.php (must be readable by the server CHMOD TO 444 fo maximum security)
VERY IMPORTANT:
DO NOT EDIT THE NAME OF THIS FILE.
DO NOT EDIT THE FIRST 2 LINE.

PHP Code:
<?php /*DO NOT ALLOW ACCESS*/ if (eregi('bd.php',$_SERVER['PHP_SELF'])) exit('Error');?>
[Enter Below Your Logins and Passwords separated by a tab]
user1    pass1
user2    pass2
hach22 is offline
Reply With Quote
View Public Profile
 
Old 12-25-2007, 09:54 AM Re: login script without mysql
multitechie's Avatar
Super Talker

Posts: 121
Trades: 0
You can add a .htaccess file with paramaters.
multitechie is offline
Reply With Quote
View Public Profile
 
Old 12-25-2007, 04:24 PM Re: login script without mysql
InfinitySchima's Avatar
Skilled Talker

Posts: 71
Name: Rafael Schimassek
Trades: 0
I use a Login Form without DB on sites where only specific selected people enter, for example an Admin Panel for a site of me. They put in the username and password and then i check it with a simple 'if'
InfinitySchima is offline
Reply With Quote
View Public Profile
 
Old 12-25-2007, 10:37 PM Re: login script without mysql
Banned

Posts: 7
Trades: 0
explore it with text file

< link drop removed >

Last edited by chrishirst; 12-26-2007 at 03:17 PM..
sukosari is offline
Reply With Quote
View Public Profile
 
Old 10-27-2008, 10:44 AM the script of hach22
Junior Talker

Posts: 2
Trades: 0
First, thanks for the script and the post. I copy and pasted it into the two files and uploaded them into my webserver. Unfortunately it gives me an error every time i try to log in with the usernames and passwords in the bd.php file. Does anybody have an idea where am i mistaking?
mariomen is offline
Reply With Quote
View Public Profile
 
Old 10-27-2008, 12:00 PM Re: login script without mysql
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
shall we guess at the error?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-28-2008, 09:34 AM Re: login script without mysql
Junior Talker

Posts: 2
Trades: 0
chrishirst, it would be very appreciated.
mariomen is offline
Reply With Quote
View Public Profile
 
Old 10-28-2008, 01:14 PM Re: login script without mysql
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
My guess is Error 10058
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to login script without mysql
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.68150 seconds with 12 queries