Web Design Forum: Login and registration tutorial, anyone got one? - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Login and registration tutorial, anyone got one? Rate Topic: -----

#1 User is offline   Lovelock 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 307
  • Joined: 12-May 11
  • Reputation: 7
  • Gender:Male
  • Location:Southampton, UK.
  • Experience:Intermediate
  • Area of Expertise:Designer

Posted 04 January 2012 - 11:31 PM

Hello,

Im looking to start a new project involving users being able to login.

I have searched for ages to find a decent tutorial but theres loads out there and none of them seem too good!

They either have issues with the scripts or the sql querys etc.

Anyone help me out?
0

#2 User is offline   Samus 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 367
  • Joined: 05-August 11
  • Reputation: 27
  • Gender:Male
  • Location:Hackney, London, UK
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 04 January 2012 - 11:49 PM

Here's one: http://net.tutsplus....ch-day-6-login/

It's written in codeigniter though. So you may have to read up on that abit, but the video tutorial is very explantory and guides you through the basic logic of a login system.
0

#3 User is offline   itodd 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 111
  • Joined: 17-April 11
  • Reputation: 29
  • Gender:Male
  • Location:UK
  • Experience:Advanced
  • Area of Expertise:Designer/Coder

Posted 05 January 2012 - 12:19 AM

I used this one as the basis for when I wrote my own login script, pretty easily to follow it and make any changes if you know any php

http://www.evolt.org...mber_me_feature
0

#4 User is online   kensha 

  • Expert
  • PipPipPipPip
  • Group: Members
  • Posts: 870
  • Joined: 12-August 10
  • Reputation: 17
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 05 January 2012 - 09:33 AM

The only thing you need to have are these codes.


<?php session_start(); ?>
<html>
<head>
<title>Login check</title>

</head>

<body>
<?php
include("msql.php");

$user=$_POST["user"];
$password=$_POST["password"];
$query=mysql_query("SELECT * FROM member WHERE Username = '$user' AND Password = '$password'");
$resultaat=mysql_fetch_array($query);
if($resultaat > 0 )
{
session_start();
$_SESSION['user']=$user;
header('location: index2.php');
}
else
{
echo "Move to the previous page" . '<a href="index.php">: Index</a>';

}
?>
</body>

</html>

Included file;
<?php
$localhost="localhost";
$user="Richard";
$password="Richard";

$verbinding=mysql_connect($localhost, $user, $password);
if(!$verbinding)
{
die("Kon geen verbinding maken");
}

mysql_select_db("richard", $verbinding);
?>


This is all you need to know.
Beside that you must start with a session() at every page and it must be placed a top.
The user id just get moved around because of the $_SESSION['user'] variable.
Warning, you can't make this as a normal variable because that's only active for 1 page.


This is mine code when the user registered on the database.

<?php
include("msql.php");

mysql_select_db("richard",$verbinding);

$sql=mysql_query("INSERT INTO member (Username, Password)
VALUES('$_POST[user]','$_POST[password]')");
?>

Warning; Those 3 script are not secured.

For security lesson you need to have a more look on the string manipulation once the parser has succeed.

This post has been edited by kensha: 05 January 2012 - 09:35 AM

0

#5 User is offline   Lovelock 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 307
  • Joined: 12-May 11
  • Reputation: 7
  • Gender:Male
  • Location:Southampton, UK.
  • Experience:Intermediate
  • Area of Expertise:Designer

Posted 05 January 2012 - 03:28 PM

I seem to keep getting this everytime...

Access denied for user 'root'@'localhost' (using password: NO)
0

#6 User is offline   webdesigner93 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,976
  • Joined: 22-September 09
  • Reputation: 222
  • Gender:Male
  • Experience:Web Guru
  • Area of Expertise:Web Developer

Posted 05 January 2012 - 03:57 PM

View PostLovelock, on 05 January 2012 - 03:28 PM, said:

I seem to keep getting this everytime...

Access denied for user 'root'@'localhost' (using password: NO)

means your database info is incorrect
0

#7 User is online   kensha 

  • Expert
  • PipPipPipPip
  • Group: Members
  • Posts: 870
  • Joined: 12-August 10
  • Reputation: 17
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 05 January 2012 - 07:35 PM

look up in your PHPMyAdmin.

Got to MySQL and then to user there you see the details you need.

Warning;
Online MySQL servers usual use the password that you use for log in on the phpmyadmin server.

This post has been edited by kensha: 05 January 2012 - 07:35 PM

0

#8 User is online   rallport 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 3,818
  • Joined: 03-January 10
  • Reputation: 266
  • Gender:Male
  • Location:England, UK
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 05 January 2012 - 09:09 PM

@kensha - are you really expecting someone to use that code?

0

#9 User is offline   webdesigner93 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,976
  • Joined: 22-September 09
  • Reputation: 222
  • Gender:Male
  • Experience:Web Guru
  • Area of Expertise:Web Developer

Posted 05 January 2012 - 10:09 PM

View Postrallport, on 05 January 2012 - 09:09 PM, said:

@kensha - are you really expecting someone to use that code?

was waiting for someone to mention that <_<
0

#10 User is offline   Samus 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 367
  • Joined: 05-August 11
  • Reputation: 27
  • Gender:Male
  • Location:Hackney, London, UK
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 06 January 2012 - 02:45 AM

View Postrallport, on 05 January 2012 - 09:09 PM, said:

@kensha - are you really expecting someone to use that code?

He stated all/most form of security was left out + the OP seems to just want to learn how a basic one is setup.
0

#11 User is online   kensha 

  • Expert
  • PipPipPipPip
  • Group: Members
  • Posts: 870
  • Joined: 12-August 10
  • Reputation: 17
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 06 January 2012 - 09:44 AM

@Samus
People are to lazy to ready now a days.

What usual happens people create scripts with a ton of security stuff in it that they don't explain further up.

The best practice is to learn how everything works.
Create a small blogging on your wamp server and once you know how everything goes around then you take care of the security.

For example, Yesterday I have created a very small forum without the security and everything seems to work correctly.
Now I have that under the knee[not the arrow in the knee] next week I'm going to secure it.
0

#12 User is offline   webdesigner93 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,976
  • Joined: 22-September 09
  • Reputation: 222
  • Gender:Male
  • Experience:Web Guru
  • Area of Expertise:Web Developer

Posted 06 January 2012 - 02:57 PM

View Postkensha, on 06 January 2012 - 09:44 AM, said:

@Samus
People are to lazy to ready now a days.

What usual happens people create scripts with a ton of security stuff in it that they don't explain further up.

The best practice is to learn how everything works.
Create a small blogging on your wamp server and once you know how everything goes around then you take care of the security.

For example, Yesterday I have created a very small forum without the security and everything seems to work correctly.
Now I have that under the knee[not the arrow in the knee] next week I'm going to secure it.



mmm it dont take much time to use mysql_real_escape_string, encrypt ur passwords and create a small function like clean_data that uses strip_tags, htmlentities etc.. people are here to learn the right way from the get go rather it takes a little more code or not.
0

#13 User is offline   gadgetgirl 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 152
  • Joined: 26-February 10
  • Reputation: 6

Posted 06 January 2012 - 03:26 PM

PHP and MySQL for Dynamic Web Sites by Larry Ullman has a chapter on user registration which is good. It is supported by an online forum. To use PHP and MySql requires a bit of set up initially - and its worth investing the time to ensure your setup is correct.
0

#14 User is offline   pat24 

  • Guru of nothing important!!
  • PipPipPipPipPip
  • Group: Members
  • Posts: 2,183
  • Joined: 29-April 08
  • Reputation: 131
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 06 January 2012 - 07:25 PM

View Postrallport, on 05 January 2012 - 09:09 PM, said:

@kensha - are you really expecting someone to use that code?



because this is the way Rallport does it.......... oh wait Rallport never gave a correct way of doing it
0

#15 User is offline   dcoder 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 7
  • Joined: 18-January 12
  • Reputation: 0

Posted 18 January 2012 - 12:13 PM

i think this also good
to know the basic
0

#16 User is offline   GalaxyTramp 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 120
  • Joined: 09-December 11
  • Reputation: 16
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 18 January 2012 - 12:35 PM

View Postkensha, on 06 January 2012 - 09:44 AM, said:

@Samus
People are to lazy to ready now a days.

What usual happens people create scripts with a ton of security stuff in it that they don't explain further up.

The best practice is to learn how everything works.
Create a small blogging on your wamp server and once you know how everything goes around then you take care of the security.

For example, Yesterday I have created a very small forum without the security and everything seems to work correctly.
Now I have that under the knee[not the arrow in the knee] next week I'm going to secure it.



I have to agree. The best way to learn is to get stuck in and have a go, then when it fails or doesn't work in the first place you dont have line after line of somebody elses uncommented code to trawl through in order to find the problem.

Get the basics working then add security, validation etc. It might seem the hard way to do it when you could cut and paste code you have found on the web, but it will be worth the extra effort.

Colin
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users