Results 1 to 6 of 6

Thread: How to create Login System for Simple Website

  1. #1
    Join Date
    Feb 2009
    Posts
    105

    How to create Login System for Simple Website

    I need a login system for my website which should consist of:

    Registration - username, password, email notification, country_name & full name

    conformation email is sent with username and pass (confirm link should be included if possible)

    login - user logs into another part of the website

    forgoten password - user enters email address registered with to receive their login information

    Any Help would be Highly Apreciated.

  2. #2
    Join Date
    Dec 2008
    Posts
    161

    Re: How to create Login System for Simple Website

    If you wanted to create your Website in PHP then here are the details of your Website design.first you have to make 5 php files called common.php-this is where all the info of what to do when registering and logining in is.

    register.php-where your users will register.


    login.php-where your users will log in.


    index.php-where your users will be redirected to after they login, you can put a link to your website here.


    And logout.php-This is where your users will be redirected to when they log out

  3. #3
    Join Date
    Jan 2006
    Posts
    211

    Re: How to create Login System for Simple Website

    To create simple login system you need to know a little of MySQL and PHP, it is very easy to use.

    First, you will need MySQL, XAMMP installed and I use PHPmyADMIN for accessing my databases. They are free for download; just search for them online. You also need to create a database in your MySQL. And as you proceed, remember that linux server file names are always case sensitives. LOGIN.PHP is not equal to login.php like on WINDOWS servers.

    Run this SQL command in your MySQL database (you must have one):

    Code:
     CREATE TABLE `users` (
    `id` int(3) NOT NULL auto_increment,
    `login` varchar(8) default NULL,
    `password` varchar(8) default NULL,
    PRIMARY KEY (`id`)
    ) TYPE=MyISAM AUTO_INCREMENT=3 ;
    
    This will create the table that will record the usernames and passwords.
    Then, create the LOGIN.PHP file. This page will contain the form that will submit the userīs data.

    PHP Code:
     <?
    session_name
    ("MyLogin");
    session_start();
    session_destroy();

    if(
    $_GET['login'] == "failed") {
    print 
    $_GET['cause'];
    }
    ?>
    Code:
    <form name="login_form" method="post" action="log.php?action=login">
    Login: <input type="text" name="user"><BR>
    Password: <input type="password" name="pwd"><BR>
    <input type="submit">
    </form>
    Now, create the LOG.PHP. This is the file that performs the action of the form.

    PHP Code:
     <?
    session_name
    ("MyLogin");
    session_start();

    if(
    $_GET['action'] == "login") {
    $conn mysql_connect("localhost","user","password"); // your MySQL connection data
    $db mysql_select_db("DATABASENAME"); //put your database name in here
    $name $_POST['user'];
    $q_user mysql_query("SELECT * FROM USERS WHERE login='$name'");

    if(
    mysql_num_rows($q_user) == 1) {

    $query mysql_query("SELECT * FROM USERS WHERE login='$name'");
    $data mysql_fetch_array($query);
    if(
    $_POST['pwd'] == $data['password']) {
    session_register("name");
    header("Location: yourpage.php"); // success page. put the URL you want
    exit;
    } else {
    header("Location: login.php?login=failed&cause=".urlencode('Wrong Password'));
    exit;
    }
    } else {
    header("Location: login.php?login=failed&cause=".urlencode('Invalid User'));
    exit;
    }
    }

    // if the session is not registered
    if(session_is_registered("name") == false) {
    header("Location: login.php");
    }
    ?>

  4. #4
    Join Date
    Oct 2008
    Posts
    167

    Re: How to create Login System for Simple Website

    Logging in Users

    To allow users to login you should build a web form, after validation of the form you can check if the user credentials are right with $user->_checkLogin('username', 'password', remember). Username and password should not be constants of course, remember is a boolean flag which if set will send a cookie to the visitor to allow later automatic logins.

    Code:
    function _checkLogin($username, $password, $remember) {
    $username = $this->db->quote($username);
    $password = $this->db->quote(md5($password));
    $sql = "SELECT * FROM member WHERE " .
    "username = $username AND " .
    "password = $password";
    $result = $this->db->getRow($sql);
    if ( is_object($result) ) {
    $this->_setSession($result, $remember);
    return true;
    } else {
    $this->failed = true;
    $this->_logout();
    return false;
    }
    }

  5. #5
    Join Date
    Apr 2009
    Posts
    1

    Re: How to create Login System for Simple Website

    I need a login with the following:
    Registration: where I make everyones accounts and know when they have been on
    Rememberance:where the site remembers what page they were on last
    Log-In and Log-Outwhere the site makes them enter a username and password to access the account and will have a logout icon/hyperlink
    Forgotten Passwordwhere i have told the site the users emails and it will send them their password if nessacery

    also it needs to be done using php files and mysql
    Thanks for any help


    p.s. can someone give me a link to a fully operational mysql program ready to download onto linux
    Last edited by Tenter25; 13-04-2009 at 11:19 PM.

  6. #6
    Join Date
    Jul 2010
    Posts
    1

    Re: How to create Login System for Simple Website

    got good stuff on this site

Similar Threads

  1. Create a simple IP Tool Batch File.
    By Bracken in forum Software Development
    Replies: 12
    Last Post: 11-12-2011, 04:33 PM
  2. Simple Website Templates
    By CrazeD in forum Windows Software
    Replies: 3
    Last Post: 30-10-2009, 10:07 AM
  3. How to create simple Chat page using PHP
    By Guns-n-Roses in forum Software Development
    Replies: 3
    Last Post: 10-09-2009, 02:11 PM
  4. Replies: 0
    Last Post: 07-03-2009, 12:39 PM
  5. simple login form in visual basic 6?
    By hariharan_00 in forum Software Development
    Replies: 3
    Last Post: 28-10-2006, 08:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •