Page 1 of 1
Login Form ---- Help Me
Posted: Tue Feb 26, 2008 12:23 am
by easyredboy
I want to facilate users by letting them make new membership.
And alsso want them to login to access differnt things in my website..
Can Anyone Help me in doing this..
Pls gimme comments

Re: Login Form ---- Help Me
Posted: Tue Feb 26, 2008 4:21 am
by Christopher
That is a very big subject. Can you be more specific and post the code you currently have.
Re: Login Form ---- Help Me
Posted: Thu Feb 28, 2008 4:54 am
by easyredboy
Pls only
just a txt file in username with all username(i can)
and a txt file in password with all password(i can)
a form in html (i can do)
php code(the worst thing, all mistake)
Re: Login Form ---- Help Me
Posted: Thu Feb 28, 2008 12:00 pm
by Christopher
Post your code.
Re: Login Form ---- Help Me
Posted: Fri Feb 29, 2008 11:24 pm
by easyredboy
easyredboy wrote:I want to facilate users by letting them make new membership.
And alsso want them to login to access differnt things in my website..
Can Anyone Help me in doing this..
Pls gimme comments

Re: Login Form ---- Help Me
Posted: Fri Feb 29, 2008 11:42 pm
by easyredboy
THE cODE IS HERE
only 4 one user now
Code: Select all
<?
$username=$_POST["username"];
$password=$_POST["password"];
$handle = fopen("username.txt", "r");
$user = fgets($handle);
fclose($handle);
$handle1 = fopen("password.txt", "r");
$pass = fgets($handle1);
fclose($handle1);
if($username == $user && $password==$pass)
{
echo "logged in!";
}
?>
Re: Login Form ---- Help Me
Posted: Sat Mar 01, 2008 4:06 am
by Benjamin
I typed this up for you just to get you started. It's just a barebones stripped down basic example and isn't very secure.
Code: Select all
# start a session
session_start();
# create an array of users
$valid_users = array('bob' => 'password',
'frank' => 'password',
'tina' => 'password');
# check login
//if (empty($_SESSION['authorized']) || $_SESSION['authorized'] !== true)
//{
// # redirect or exit
// exit();
//}
# wrapper for post vars saves typing
function post($x)
{
return emtpy($_POST[$x]) ? null : trim($_POST[$x]);
}
if (post('doLogin'))
{
$user = post('userName');
if (empty($valid_users[$user]))
{
# user doesn't exist
}
if (post('user_password') != $valid_users[$user])
{
# password was wrong
}
# log em in
$_SESSION['authorized'] = true;
}
Re: Login Form ---- Help Me
Posted: Sat Mar 01, 2008 6:49 am
by easyredboy
Thanx for ur help!
I need one frm which i can import one frm a file
isnt my code correct?
i never get logged in
whats the problem
Re: Login Form ---- Help Me
Posted: Sat Mar 01, 2008 9:37 am
by staar2
I see you use text files but my suggestion is to use mysql. Database would more secure and you have less change to mess it up. But if you keep using text files then at least encrypt the password data.

Re: Login Form ---- Help Me
Posted: Sat Mar 01, 2008 10:33 am
by Christopher
easyredboy wrote:Thanx for ur help!
I need one frm which i can import one frm a file
isnt my code correct?
i never get logged in
whats the problem
Your code is correct ... but a little crazy. It appears that you have one file containing only a username and another file containing only a password. Typically, if you wanted to use a text file, you would have a delimited file like this:
You can use file() to read that in. You also might want to look into Ninja's CSV class library.
Re: Login Form ---- Help Me
Posted: Sun Mar 02, 2008 5:14 am
by easyredboy
plz can u gimme the code for reading the file which contains username n password