|
|
|
|
![]() ![]() |
Feb 21 2007, 01:00 AM
Post
#1
|
|
|
Super Member Group: [HOSTED] Posts: 702 Joined: 12-July 06 From: Ontario, Canada Member No.: 14,464 |
It turns out that the authentication script that I copied from http://www.php-mysql-tutorial.com/user-aut...on/database.php doesn't work even when it is left unchanged. What a crappy piece of code.
Now I am trying to build by own login script from scratch. I already have a little knowledge on how to do this (connecting, echoing, retrieving) but I need some more examples and/or tips. I know what I need and maybe this could help you out: Note: Green items are fixed.
That's all I need right now. For everyone who helps, I will mention your Trap17/Astahost username into the the credits page of the site when it is completed! |
|
|
|
Feb 21 2007, 01:54 AM
Post
#2
|
|
|
Premium Member Group: [HOSTED] Posts: 495 Joined: 5-November 06 Member No.: 17,016 |
It turns out that the authentication script that I copied from http://www.php-mysql-tutorial.com/user-aut...on/database.php doesn't work even when it is left unchanged. What a crappy piece of code. Now I am trying to build by own login script from scratch. I already have a little knowledge on how to do this (connecting, echoing, retrieving) but I need some more examples and/or tips. I know what I need and maybe this could help you out: Note: Green items are fixed.
I'm assuming you're going to use php as your programming language. I've just posted some tips regarding this here http://www.astahost.com/authentication-script-t14988.html As for ip address, you can always get it from the server's variable $_SERVER['REMOTE_ADDR'] and $_SERVER['REMOTE_HOST'] Authorization is just keeping a bit or 2 to indicate the user's status and use the login script to decide what to do with different bit. Same goes or moderator. Lost password is slightly tougher. You'll need to know how to send email, then you have to choose either let the user key in their own password after they click the "recover password" link on their email, or provide them a temporary password so they can change it later. Just get the hang of it first. We can come to the detail later, step by step, which is easier to cop with. Good Luck |
|
|
|
Feb 21 2007, 04:39 AM
Post
#3
|
|
|
PESTICIDAL MANIAC Group: Members Posts: 626 Joined: 1-September 04 From: Auckland, New Zealand Member No.: 27 |
1) Is your script that you are using based similar off this script you provided in the links?
2)Is there anything different from it that you have done apart from what you're asking for and have already fixed? 3)What version of PHP should this cater for or would you like it to be compatible with PHP3 and up? I might just improve on this script, keeping it similar to how it's structured it's tables for the database, give me a few hours to have something whipped up. Cheers, MC |
|
|
|
Feb 22 2007, 12:43 AM
Post
#4
|
|
|
Super Member Group: [HOSTED] Posts: 702 Joined: 12-July 06 From: Ontario, Canada Member No.: 14,464 |
1. It can be based off the one given in the previous topic (Authentication Script), but I am going to whip something up anyways (maybe similar, maybe not
2. No, just something that works. 3. I have this information provided by cPanel in Trap17. QUOTE Apache version 1.3.37 (Unix) MySQL version 5.0.27-standard PostgreSQL version 7.4.13 PHP version 5.1.6 So I guess compatibility for PHP 5+ is okay. I already have the registration thing setup okay. I used to have a version that works, but somehow it has malfunctioned (OMG BACKUP!!!) and now I have nothing else to modify upon. |
|
|
|
Feb 24 2007, 04:05 PM
Post
#5
|
|
|
Super Member Group: [HOSTED] Posts: 702 Joined: 12-July 06 From: Ontario, Canada Member No.: 14,464 |
Okay, I have whipped up this code and IT WORKS!!!
CODE <?php session_start(); $name = $_POST['username']; $password = $_POST['password']; $con = mysql_connect("localhost","portal_xkingdom","Yahoo!rocks"); if(!$con) { die('Sorry, the XKingdom Center database has encountered an error right now. Please try again later or contact the website administrator. The MySQL error is: ' . mysql_error()); } mysql_select_db("portal_xkingdom", $con); $result = mysql_query("SELECT * FROM users WHERE name='$name' and password = '$password'"); $auth = mysql_query("SELECT auth FROM users"); $rowcheck = mysql_num_rows($result); if($rowcheck==1) { /* while($auth_check = mysql_fetch_array($auth)) { if($auth_check==YES) { */ $_SESSION['db_is_logged_in'] = true; setcookie("user", "$name", time()+86400); header('Location: moderate.php'); header('(anti-spam-content-type:) text/html;charset=iso-8859-1'); /* } elseif($auth_check==NO) { $error="You are not authorized as an XKingdom Member yet. Please try again later. If this problem persists for more than 24 hours, please contact the website administrator."; } }*/ } elseif($rowcheck>1) { $error="You have entered an incorrect username/password combination. Please try again. If you forgot your password, contact the website administrator."; header('(anti-spam-content-type:) text/html;charset=iso-8859-1'); } header('(anti-spam-content-type:) text/html;charset=iso-8859-1'); mysql_close(); ?> I have built the code from scratch using the W3Schools help and my previous knowledge from browsing a variety of downloaded PHP scripts which DIDN'T work. I have commented out the authorization part because it isn't working. This means that I have re-met the green requirements This post has been edited by FirefoxRocks: Feb 26 2007, 11:00 PM |
|
|
|
May 18 2007, 07:40 AM
Post
#6
|
|
|
Member - Active Contributor Group: Members Posts: 91 Joined: 18-May 07 Member No.: 22,008 |
QUOTE You don't need to make a login page from scratch. That'd be like ... like... working. o_O. I suggest going to planetsourcecode.com, search ALS (Advance Login System) and download it. extract it to your htdocs, and open install.php. It has a register/login system, email activation system, secure pages for higher members and admins, a message center, news, and even member hiearchy. If you want to make one from scratch, I suggest reading the php files of the ALS and checking to see how it was made. Good luck. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 13th October 2008 - 04:24 PM |