Jump to content
The Uniform Server Community
Tucker

Login System...

Recommended Posts

Ok I have been trying to make a login system, but it never works. Honestly Im about to give us... It's driving me insane. So now I ask can you guys help me.

 

Well first I better explain what needs to be involved in the system, because it's going to be esential for my site, it needs this login system so you can login and out very easily, and also it cant be stored in cookies you know what I mean.

 

Anyway so where do I start off with? :)

Share this post


Link to post
Share on other sites

Start of with making the database and tables needed. Also the information you will be collecting form users during registration and then we move on to programming.

Share this post


Link to post
Share on other sites

Got all that figure out. at this point only need:

Username:

Password:

Retype Password:

Email:

Retype email:

Visual Confirmation:

 

You know where you have to type in the numbers that appear like an image thing, what ever they are called.

I also want it, so it sends an email for an activation of the account.

Oh the table is called user.

Share this post


Link to post
Share on other sites
You know where you have to type in the numbers that appear like an image thing, what ever they are called.

they are called captchas (completely automated turring test to tell computers and humans apart)

Share this post


Link to post
Share on other sites

Those do not go in the database. They are randomly generated by PHP and tested to see if the user input is the same as the input generated. :)

 

Are you done with the databse?

 

BTW: We will leave the varification option and do that last just so we do not mess everything up :D

Share this post


Link to post
Share on other sites

Well i think it's done for now. It is possible to store in when they last visited right? Also when they registered as well? Apart from that I think that's it.

Share this post


Link to post
Share on other sites

Yes, it is possible to do that :)

 

Just put it in the user table :)

 

PS: I wish i had time to write it for you but i will just be joking if i said i did. Also, i am using modem connection where i am so, my time on the net is limited because i am tieing down the phone line. :)

 

Here is what we will do, we will start with the login and logout and then the others...

 

I will start on the code for you and then attach it. I will also put comments there to help you understand :D

 

Also, the first scripts will just be the login and logout, no registration or anything. Try and attch the .sql file as a .txt file so i can know what table and co. you are set to use.

Share this post


Link to post
Share on other sites

No, no. It's fine that you help that way. It will help me learn to get this right. Honestly, I am always lost when it comes to keeping logged in etc...

Share this post


Link to post
Share on other sites

would that just be the user table in this case?

Share this post


Link to post
Share on other sites

This is a "login" script thatwill work for anyone to "log in". ;D

 

Note: This is not a register script, this is a login script.

 

The $SESSION['login'] = true; means that they're logged in. Okay? Okay.

That also means it requires a session_start(); in the script. So place this where it's needed.

 

I will include something that you need to do yourself, for example, the forms and also the database queries.

 

/* Start of script */

// login.php

/*

Created by: Falc

 

15 February 2006

Language: PHP

License: Do what ever you like. However, I'd like to to keep my nickname(creator) in. If not, no big deal I suppose but I would like just that in return for posting this. Thanks.

*/

session_start();

 

if ($_POST['password'] == NULL && $_POST['username'] == NULL) {

// If the user has not posted anything in the user column.

/* Display the form here, send it to login.php (this file)

and also the field names need to be 'username' and 'password */

}

else{

// if the user has entered something

 

$query = "SELECT password FROM table where username = '".$POST['username']."'";

$result = mysql_query($query);

$sqlpass = mysql_fetch_array($result);

 

/* the SQL code will obviously need to be changed to suit the table

layout but it should be enough. */

 

if ($POST['password'] == $sqlpass['password']) {

// If the posted password is the same as stored in the database

 

$SESSION['login'] = true;

 

echo "You are now logged in, yay.";

}

else {

// If this isn't true, however

 

echo "I'm sorry but the password or the username you entered is incorrect.";

}

 

}

 

/* End of script */


Known Languages:
adv-XHTML, int-PHP, int-SQL, int-CSS, beg-Python

Currently reading: Take off in Japanese, How to play popular piano in 10 easy lessons, The Magicians' Guild
Currently learning: Python, Piano, Japanese
Current project: Relaxing
Currently playing: FalcHedgehog.gif

Share this post


Link to post
Share on other sites

The script should work fine provided that the MySQL database/tables are correctly created.

http://forum.uniformserver.com/index.php?a...DE=02&f=21&t=38

This is an example table with adding 1 users inside of it.

 

Theres 2 SQL scripts for this...

Creating the table:

CREATE TABLE table

(

username varchar(30),

password char,

id int(15) AUTO_INCREMENT PRIMARY KEY

);

 

Adding the users:

INSERT INTO table (username, password)

VALUES ("foo", "bar");


Known Languages:
adv-XHTML, int-PHP, int-SQL, int-CSS, beg-Python

Currently reading: Take off in Japanese, How to play popular piano in 10 easy lessons, The Magicians' Guild
Currently learning: Python, Piano, Japanese
Current project: Relaxing
Currently playing: FalcHedgehog.gif

Share this post


Link to post
Share on other sites

:) Right now i am too busy so sorry... can't help. I bearly have time for myself.... just school and work.. and i do not even get to watch TV :)

 

ahhhhhhhhhhh... :)

Share this post


Link to post
Share on other sites

I just went with Simpleauth for this type of thing and custom built my PHP around it. I even added md5 encryption! It was so easy to change a line here or there it just had the perfect basics for anyone who has an idea of mySQL and PHP.

Share this post


Link to post
Share on other sites

HuH thanks for the help there :lol: Believe it or not I was just looking for something like this :angry:

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...