|
|
|
|
![]() ![]() |
Jan 6 2006, 01:50 AM
Post
#21
|
|
|
Newbie [Level 2] ![]() ![]() Group: Members Posts: 26 Joined: 2-January 06 Member No.: 16,526 |
Huh i dont know... Do i need to insert some table in db ?? Where will be stored accounts i know i need to have user name for db, and to have database but i need to have in database and table for accounts to store it??
|
|
|
|
Jan 6 2006, 01:33 PM
Post
#22
|
|
|
Member [Level 2] ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 87 Joined: 12-March 05 From: somewhere in the UK...if only I knew Member No.: 4,419 |
You see this is why programming newbs should not copy articles cos information is misleading...
And by the looks of it this script requires only one talbe... the collums would be name age login password password2 I would not be sure about the setting of these collums as I would need to test the script which I dunno if I really want to cos this script looks very...well...whatg more can I say if conn.php was missed out sorry to reply to my own post but I forgot to add: ernad this table will be put within a db which will store your users accounts...it is better if you just go to hotscripts.com and search for a login script cos im not too sure if this tutorial should have been accepted... |
|
|
|
Jan 6 2006, 10:27 PM
Post
#23
|
|
|
Newbie [Level 2] ![]() ![]() Group: Members Posts: 26 Joined: 2-January 06 Member No.: 16,526 |
here is sql:
QUOTE CREATE TABLE `members` ( `name` varchar(60) character set utf8 default NULL, `email` varchar(255) character set utf8 NOT NULL, `age` varchar(3) character set utf8 default NULL, `login` varchar(50) character set utf8 NOT NULL, `password` varchar(40) character set utf8 NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; and i`m edited page: register: QUOTE <? include("conn.php"); // create a file with all the database connections if($do_register){ // if the submit button were clicked if((!$name) || (!$email) || (!$age) || (!$login) || (!$password) || (!$password2)){ print "You can't let any fields in blank.\n"; // if the user did not put some field exit; } $name = stripslashes($name); $email = stripslashes($email); $age = stripslashes($age); $login = stripslashes($login); $password = stripslashes($password); $password2 = stripslashes($password2); // this is for security reasons if($password != $password2){ // if passwords didn't match print "The password and the confirmation are not the same!\n"; exit; } $password = md5($password); mysql_query("INSERT INTO members (name,email,age,login,password) VALUES ('$name','$email',$age,'$login','$password')") or die (mysql_error()); header("Location: login.php"); exit; } // close the first "if" ?> <form action="register.php" method="post"> Name: <input type="text" name="name"><br> Email: <input type="text" name="email"><br> Age: <input type="text" name="age"><br> Login: <input type="text" name="login"><br> Password: <input type="password" name="password"><br> Password Again: <input type="password" name="password2"><br> <input type="submit" name="do_register" value="Sumbit"> </form> login.php: QUOTE <? include("conn.php"); if($do_login){ $login = stripslashes($login); // VERY IMPORTANT FOR SECURITY OF YOUR DATABASE DON'T ERASE IT $passwd = stripslashes($passwd); // VERY IMPORTANT FOR SECURITY OF YOUR DATABASE DON'T ERASE IT $check = mysql_query("SELECT * FROM members WHERE login='$login' LIMIT 1;"); $user = mysql_fetch_array($check); if($user[password] == md5($passwd)){ // if the writed password and the db password are the same... setcookie("login","$login",time()+360000); setcookie("pass","$passwd",time()+360000); // ...set the cookies... header("Location: userspage.php"); // ...and redirect to restrict page }else{ print "Login or password incorrects!\n"; exit; } } ?> <form action="login.php" method="post"> Login: <input type="text" name="login"><br> Passwd: <input type="password" name="passwd"> <input type="submit" name="do_login" value="Log-in!"> </form> verify.php : QUOTE <? include("conn.php"); // include page with the database connection $cookie = $HTTP_COOKIE_VARS; // to reduce the var's name if($cookie[login] && $cookie[pass]){ $login = $cookie[login]; $pass = $cookie[pass]; $usrquery = mysql_query("SELECT * FROM members WHERE nick='$login' AND password='$pass';") or die (mysql_error()); // search for the user $user = mysql_fetch_array($usrquery); if($user[level] != 'Admin') header("Location: notfound.htm"); // if the user is not an admin, redirect to an error page } ?> Now will work |
|
|
|
Jan 22 2006, 11:13 PM
Post
#24
|
|
|
Hidden Secrets can't be told threw just words. One must feel what the other feels to truely understand... ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1,523 Joined: 8-January 06 From: Sacramento California Member No.: 16,756 |
i can never get codes like these to work >_< it kinda sucks, it keeps teling me-
$host = 'localhost'; $user = 'albus_chris'; $pass = 'dontuwish'; $db = 'albus_login'; mysql_connect($host,$user,$pass) or die ("Database is unavaiable. Please try again later."); mysql_select_db($db) or die ("Database is unavaiable. Please try again later."); at the top of evey page..ne clue whats going on? the conn.php file should look exactly like this right? CODE $host = 'localhost'; $user = 'albus_albus'; $pass = 'PWHERE; $db = 'albus_login'; mysql_connect($host,$user,$pass) or die ("Database is unavaiable. Please try again later."); mysql_select_db($db) or die ("Database is unavaiable. Please try again later."); or is it supposed to look different? i copied it from the origional post here and it didn't work.. please help! maybe i have the code wrong, i hope that is the problem >_< |
|
|
|
Jan 28 2006, 08:14 AM
Post
#25
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 286 Joined: 4-December 05 From: Latvia, Riga Member No.: 15,337 |
I edited this scripts after ernads post.. here is what problems now I have:
admin.php profiles.php verify.php when open these page sit shows Unknown column 'nick' in 'where clause' and when user fills register form it is redirected to login page.. but when it trys to login it always says incorrecty login or password.. what should I do? |
|
|
|
Jan 29 2006, 02:35 PM
Post
#26
|
|
|
Newbie [Level 3] ![]() ![]() ![]() Group: Members Posts: 49 Joined: 19-January 06 Member No.: 17,375 |
merci bouceup
This post has been edited by jlhaslip: Jan 29 2006, 06:48 PM |
|
|
|
Aug 24 2006, 11:29 AM
Post
#27
|
|
|
Premium Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 175 Joined: 10-September 05 Member No.: 11,692 |
How do you create the SQL database fields that are needed for this file?
|
|
|
|
Aug 25 2006, 06:50 AM
Post
#28
|
|
|
Member [Level 1] ![]() ![]() ![]() ![]() Group: Members Posts: 50 Joined: 25-August 06 Member No.: 28,897 |
I think it's better to use PHP SESSION than COOKIE. coz some user may disabled it. something like this:
CODE if ($do_login) { $query = mysql_query("SELECT * FROM members WHERE login='$login' AND password='$password'); if (mysql_num_rows($query) > 0) { $_SESSION['logged'] = $login; // some code here } else { print 'Username or password did not match'; exit; } } So, in every members page we can use: CODE if (!isset($_SESSION['logged']) { // if not logged in } else { // member page goes here } Just an advice! This post has been edited by masterio: Aug 25 2006, 06:53 AM |
|
|
|
|
|