Reply
Member Log In Script without mysql
Old 01-03-2005, 06:34 PM Member Log In Script without mysql
Super Talker

Posts: 116
Trades: 0
I know that it is possible to have a member log in script so that members can only access certain pages WITH mysql, but I was wondering if this is possible WITHOUT mysql. any help would be greatly appreciated.
nasaboy007 is offline
Reply With Quote
View Public Profile Visit nasaboy007's homepage!
 
 
When You Register, These Ads Go Away!
Old 01-03-2005, 07:17 PM
theshiznit's Avatar
Registered User

Posts: 214
Trades: 0
here it is!


PHP Code:

<?php

if (isset ($_POST['submit'])) {

$problem FALSE;

if (empty (
$_POST['username'])) {
  
$problem TRUE;
print 
'please enter a username!';

}

if (empty (
$_POST['password'])) {
  
$problem TRUE;
print 
'Please enter a password'

}

if (empty (
$_POST['password2'])) {
  
$problem TRUE;
print 
'Your password did not match your confirmed password';

}

if ( !
$problem )
 
if (
$fp fopen 'users.txt''ab' ) {   //Open the file!

$dir time() . rand 904596);

$data $_POST['username'] . "\t" crypt($_POST['password'] . "\t" $dir "\r\n";

// Write data and close file!

fwrie $fp$data );
fclose $fp );

mkdir $dir )

print 
'You are now registered!';

} else {

   print 
'You could not be regiseter due to an error';

}


} else {

print 
'Please try again!'

}

} else {

?>
Ok first make a text file called "users.txt" and give it write permissions. Now save the PHP{ file above as "register.php"

HTML Code:
<form action="register.php" method="post">

Username: <input type="text" name="username">

<br /><br />

Password: <input type="password" name="password">

<br /><br />

Confirm Password: <input type="password" name="password2">

<br /><br />

<input type="submit" name="submit" value="register">

</form>
That was the registration form, now I am going to make the login form!



PHP Code:

<?php

if (isset ($_POST['submit'])) {

$loggedin FALSE;

$fp fopen 'users.txt''rb' );

while ( 
$line fgetcsv ($fp100"\t")) {

if ( (
$line[0] == $_POST['username']) AND ($line[1] == crypt ($_POST['password'], l$line[1]) ) ) {

$loggedin TRUE;

break;

}

}

if (
$loggedin) {

print 
'You are now logged in!';

} else {

print 
'The username and password did not match!';

?>
Now I am going into the login form! Save this file as login.php

HTML Code:
Username: <input type="text" name="username">

<br /><br />

Password: <input type="password" name="password">

<br /><br />

<input type="submit" name="submit" value="log in!">

If something doesn't work, then PM me!

BTW CUSTOM MADE BY ME!!!

Last edited by theshiznit; 01-03-2005 at 07:22 PM..
theshiznit is offline
Reply With Quote
View Public Profile
 
Old 08-12-2009, 10:14 PM Re: Member Log In Script without mysql
Junior Talker

Posts: 1
Name: Juan Delgado
Trades: 0
Hi there, my name is Juan Delgado.

You don't know for how long I have been searching for what you just give to me: (Log in Script) for an membership site.

Please I do have some problem getting it to work, you think it's possible we can talk using Skype? my username: juande40

Please help me out with these.

Juan Delgado

Last edited by chrishirst; 10-31-2009 at 10:36 AM..
jr2delgado is offline
Reply With Quote
View Public Profile
 
Old 10-31-2009, 02:38 AM Re: Member Log In Script without mysql
Junior Talker

Posts: 1
Name: kaly
Trades: 0
Hi

Can you please let me know if the given code worked. I need to store encrypted passwords in a file just the way you did in your sample.

Thanks.
kaly is offline
Reply With Quote
View Public Profile
 
Old 10-31-2009, 10:37 AM Re: Member Log In Script without mysql
chrishirst's Avatar
Super Moderator

Posts: 22,260
Location: Blackpool. UK
Trades: 0
FOUR YEARS AGO THIS THREAD WAS STARTED!!!!!!!!

I doubt there will be a reply from the OP now!!!!
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-31-2009, 12:15 PM Re: Member Log In Script without mysql
Super Talker

Posts: 109
Name: Not Telling
Trades: 0
You only need to add 1 line of code to all of your pages you want to protect and that's all. You need to login only once and all protected pages will be available for you.

http://phpf1.com/product/site-protector-script.html

Its very simple and you can change the css.

Its basicly stores the password in a flat file.
__________________
MY MSN: Sith717@Hotmail.com
PHP, HTML, and CSS Coding, Logo and Web Design - Professionally done.
PM me anytime for HTML, PHP or web design help. I will be glad to help you out.
sith717 is offline
Reply With Quote
View Public Profile
 
Old 10-31-2009, 01:43 PM Re: Member Log In Script without mysql
King Spam Talker

Posts: 1,410
Trades: 0
Chris is right this is a very old thread and that script as posted is buggier that a dead body in the swamp for a week.

If you still want to play try this:

Create an empty text file named users.txt
Copy this code to a file named signup.html
PHP Code:
<html>
<
body>
<
form action="register.php" method="post">
Username: <input type="text" name="username">
<
br /><br />
Password: <input type="password" name="password">
<
br /><br />
Confirm Password: <input type="password" name="password2">
<
br /><br />
<
input type="submit" name="submit" value="register">
</
form>
</
body></html
Copy this code to a file named register.php

PHP Code:
<?php 
//debug
echo "password1 ".$_POST['password'];
echo 
"<br>";
echo 
"password2 ".$_POST['password2'];
echo 
"<br><br>";
// end debug
 
if (isset ($_POST['submit'])) { 
$problem FALSE
if (empty (
$_POST['username'])) { 
  
$problem TRUE
print 
"Please enter a username!"

if (empty (
$_POST['password'])) { 
  print 
"Please go back and enter a password" ;
exit;

if (empty (
$_POST['password2'])) { 
 
print 
"Please go back enter your password in each box."
exit;

if ((
$_POST['password'])!==($_POST['password2']))
{
print 
"Your password entries did not match! Please go back and correct them"
exit;
}
// First thing is to be sure that the usename is not in use by someone else
$fp fopen 'users.txt''rb' ); 
while (
$line fgetcsv($fp,100,",")) { 
echo 
$line[0]."&nbsp;&nbsp;".$line[1];//debug ONLY! Allows you to see database contents. 
echo "<br>"//debug
if ( ($line[0] == $_POST['username']) ) { 
echo 
"<b>Sorry! That username is already being used. Please go back and select another name.</b>";
fclose $fp ); 
exit;

}
 
// if there is no problem open the file and write to it
   
$fp=fopen('users.txt''ab' ); 
//$data =($_POST['username']).crypt($_POST['password']); 
$data =($_POST['username']).",".($_POST['password'])."\r\n"
// Write data and close file! 
fwrite $fp$data ); 
fclose $fp ); 
print 
"You are now registered!"
}
exit;
?>
Copy this code to a file named login.php
PHP Code:
<?php 
//debug
echo $_POST['username'];
echo 
"<br>";
echo 
$_POST['password'];
echo 
"<br>";
// end debug
 
if (isset ($_POST['submit'])) { 
$loggedin FALSE
$fp fopen 'users.txt''rb' ); 
while (
$line fgetcsv($fp,100,",")) { 
echo 
$line[0]."&nbsp;&nbsp;".$line[1];//debug ONLY! Allows you to see database contents. 
echo "<br>"//debug
if ( ($line[0] == $_POST['username']) AND ($line[1] == ($_POST['password']) ) ) { 
$loggedin TRUE
echo 
"line 24 <br>"//debug
//break; 


if (
$loggedin) { 
print 
'<br>The password and username are verified.'
echo
"<br><br>Now what do you want to do with that login?";
echo
"<br><br> I am guessing that this is where you start learning all about sessions.";
echo 
"(evil grin)";
exit;
} else { 
print 
'<br>The username and password did not match!'
}
}
?> 
<form action="login.php" method="post">
Username: <input type="text" name="username">
<br /><br />
Password: <input type="password" name="password">
<br /><br />
 
<input type="submit" name="submit" value="Login">
</form>

You may have to chmod users.txt to 777 to get it to work but try the following first in this order:
666, 766
Default on most servers is 666. Running on localhost on your windows machine chmod is not necessary
Note the encryption has been removed until you finish playing and figure out how you are going to use this.

Have fun! This entertained me for a few hours on a rainy Saturday morning.

__________________
Colbyt
colbyt is online now
Reply With Quote
View Public Profile
 
Old 11-01-2009, 06:33 AM Re: Member Log In Script without mysql
orionoreo's Avatar
Ultra Talker

Posts: 261
Name: Jerry
Trades: 0
i wrote one that uses an array instead of writing to another file so no need to change chmod using a different secure algorithm

http://www.crankberryblog.com/2009/s...thout-database

if the above doesn't work you could try mine
orionoreo is offline
Reply With Quote
View Public Profile
 
Old 11-01-2009, 08:38 AM Re: Member Log In Script without mysql
King Spam Talker

Posts: 1,410
Trades: 0
Your's is more secure for sure. With my limited sql security experiece I prefer passwords in a file/array versus in a database.

The only limitation is regisration which many sites do not desire.
__________________
Colbyt
colbyt is online now
Reply With Quote
View Public Profile
 
Reply     « Reply to Member Log In 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.14731 seconds with 13 queries