Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

this user logon works, perfectly

Status
Not open for further replies.

parthshukla

Programmer
Joined
May 27, 2003
Messages
5
Location
AU
hello guys,

chech this one out it will do a lot if you are making an authorized area.....

befor you write this make a table or a seprate database if you like in mysql...

call it what you like, i have called in this example the databse login and the table usercheck
make the table with two field one is user and the other pass, and when you insert data into that choose password function in the pass field, which you will find in the mysql thing....
index.php

<?php

if (isset($HTTP_POST_VARS['user']) && isset($HTTP_POST_VARS['password']))
{
//if the user just tried to log on
$user = $HTTP_POST_VARS['user'];
$pass = $HTTP_POST_VARS['password'];
$db = mysql_connect('localhost','root','yourpassowrd');
mysql_select_db('login',$db);
$query = &quot;select * from `usercheck` where user='$user' and pass=password('$password')&quot;;
$result = mysql_query($query);
$usercheck = mysql_num_rows($result)'

if ($usercheck == 1)
{
$HTTP_SESSION_VARS['valid_user'] = $user;
}
else
{
echo &quot;Not authorized to view this page&quot;
}

}
else
{
if (isset($HTTP_SESSION_VARS['valid_user']))
{
echo &quot;You are logged in as: &quot;. $HTTP_SESSION_VARS['valid_user'];
//put your stuff here, which you want a valid user to see
}
else
{
//put you form here, i haven't got time right now so you can make that part by your self
}
}
?>

this is the one it work with mine, but i haven't copied and pasted because i am at a pubic computer, but i think it will work i am still working on the logout page for this script, i will put it up when i've finished making but, you know give me some feedback at this or question, that will do...

Parth.....

 
If you think a code snippet is useful, please create a FAQ. This thread will eventuall drop off the first page of the forum and be difficult to find later.

Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top