Jump to content
xisto Community
FirefoxRocks

Login Script PHP Help #3 - Need help creating one

Recommended Posts

It turns out that the authentication script that I copied from http://forums.xisto.com/no_longer_exists/ 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.

No duplicate username in MySQL Database

Authorized users only. I have to authorize each user or else a message comes up that says that they have not been authorized yet.

IP address logging. This means logging the IP address when registered and logging the IP address at last logon.

After logon, it all redirects to one page (if certain group).

If the username is in moderator status, it redirects to the Moderator Page. Otherwise, it redirects to the Member page.

A lost password function.

That's all I need right now. For everyone who helps, I will mention your Xisto/Xisto username into the the credits page of the site when it is completed! ;) ;)

Share this post


Link to post
Share on other sites

It turns out that the authentication script that I copied from http://forums.xisto.com/no_longer_exists/ 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.

No duplicate username in MySQL Database

Authorized users only. I have to authorize each user or else a message comes up that says that they have not been authorized yet.

IP address logging. This means logging the IP address when registered and logging the IP address at last logon.

After logon, it all redirects to one page (if certain group).

If the username is in moderator status, it redirects to the Moderator Page. Otherwise, it redirects to the Member page.

A lost password function.

That's all I need right now. For everyone who helps, I will mention your Xisto/Xisto username into the the credits page of the site when it is completed! ;) ;)
I'm assuming you're going to use php as your programming language.

 

I've just posted some tips regarding this here

http://forums.xisto.com/topic/92508-topic/?findpost=1064365378

 

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 Xisto.

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.

Share this post


Link to post
Share on other sites

Okay, I have whipped up this code and IT WORKS!!! :P;) ;)

<?phpsession_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 ;) Now i just need to meet the other requirements, which number isn't that important. I need some more help with that.
Edited by FirefoxRocks (see edit history)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.