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 + Registration Script - MySQL
Old 02-25-2008, 10:18 PM Login Script + Registration Script - MySQL
Junior Talker

Posts: 3
Trades: 0
I saw a few scripts that didn't really need MySQL, but they didn't work for me for some reason....

Well the one i have is this: http://69.249.243.110/login.rar

I want something like that :P just one that works! Thank you so much in advance!
billenium is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-25-2008, 10:29 PM Re: Login Script + Registration Script - MySQL
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
404 not found. Otherwise I'd write one up pretty quickly.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 02-25-2008, 10:37 PM Re: Login Script + Registration Script - MySQL
Junior Talker

Posts: 3
Trades: 0
My bad... Caps matter

http://69.249.243.110/Login.rar

There you go! Thanks
billenium is offline
Reply With Quote
View Public Profile
 
Old 02-25-2008, 11:38 PM Re: Login Script + Registration Script - MySQL
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
First off I don't know what you want to use a .txt file for a database and not mysql, it's not as safe. http://www.db4free.net/index.php?sec...tent=d4f_apply that's where you can get free mysql.
You WILL need PHP for this.
The first file is the register file named register.php :
PHP Code:
<?php $user $_POST['user'];
$pass $_POST['pass'];
$pass1 $_POST['pass1'];
if(
$user != '' && ($pass != '' && $pass == $pass1)){
    
$text file('users.txt');
    
$textarray_reverse($text);
    foreach(
$text as $line){
        list(
$name,$code) = split('::''$line');
        if(
$user == $name){header('Location: login.php?msg=1');exit;}
    }
    
$file "users.txt";
    
$fe fopen($file'a') or die("Can't open file for writing.");
    
$data $user."::".md5($pass);
    
fwrite($fe$data);
    
fclose($fe);
    
header('Location: login.php?msg=2');
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Registration</title>
</head><body>
<form action="register.php" method="post"><fieldset><legend>User and Pass</legend><input type="text" name="user"><input type="password" name="pass">Confirm Password: <input type="password" name="pass1"><input type="submit" value="Register"></form>
</body></html>
This is the login file, login.php :
PHP Code:
<?php session_start();
$user $_POST['user'];
$pass $_POST['pass'];
$msg $_GET['msg'];
if(
$user != '' && $pass != ''){ 
    
$text file('users.txt'); 
    
$textarray_reverse($text); 
    foreach(
$text as $line){ 
        list(
$name,$code) = split('::'$line); 
        if(
$user == $name && md5($pass) == $code){$_SESSION['user'] = $user$_SESSION['pass'] = $passheader('Location: index.php');exit;}
}
echo 
"Username or password bad, please try again.";
}
if(
$msg == 1){
echo 
'Username taken please login if it\'s yours or try to <a href="register.php">register</a> again.';}
if(
$msg == 2){
echo 
"Registration successful, please login below.";}?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html> 
<head> 
<meta http-equiv="content-type" content="text/html;charset=utf-8"> 
<title>Login</title> 
</head><body> 
<form action="register.php" method="post"><fieldset><legend>Login Form</legend><input type="text" name="user"><input type="password" name="pass"><input type="submit" value="Register"></form>
<p>Don't have a login? Get one now, <a href="register.php">register</a>.</p>
</body></html>
Lastly the way users.txt would look:
Code:
Username::MD5hash
For example:
Code:
test::098f6bcd4621d373cade4e832627b4f6
Any page that you want to use the session on you'll have to have start with
PHP Code:
<?php session_start();
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>

Last edited by Arenlor; 02-27-2008 at 05:04 PM.. Reason: Corrected the code, again
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Reply     « Reply to Login Script + Registration Script - 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.28137 seconds with 12 queries