Results 1 to 7 of 7

Thread: Simple php login script for Beginners

                  
   
  1. #1
    Moderator Array vengad11's Avatar
    Join Date
    Jan 2010
    Location
    LK
    Posts
    217
    Post Thanks / Like
    Blog Entries
    4
    Rep Power
    3
    Follow vengad11 On Twitter Add vengad11 on Facebook

    Smile Simple php login script for Beginners







    php login script, shown below, uses HTML form for data input, and extraction of existing logins and passwords is made from MySQL database. Access to page.php is closed, but with the help of authorization we can receive access to it:

    Code:
    <?
    session_start(); //initialize session mechanism
    
    if(!isset($_POST['ok'])) {
    // if the form is not completed, display it
        echo"
        <html>
        <head>
        <title>Authorization page</title>
        </head>
        <body>
        <table width='100%' height='100%'>
        <form method='POST' action='login.php'>
        <tr><td align=center>
        <table>
        <tr><td>
        <table>
        <tr><td>Login:</td><td><input type='text'
            name='login' size='15'></td></tr>
        <tr><td>Password:</td><td><input
            type='password' name='pass' size='15'></td></tr>
        </table>
        </td></tr>
        <tr><td align=center><input type='submit' name='ok'
            value='Enter'></td></tr>
        </table>
        </td></tr>
        </form>
        </table>
        </body>
        </html>
        ";
    }
    else{    
        //supposed that user data
        //is saved in database, in users table, that includes id, login, pass fields
    
        $db=mysql_connect('host', 'login', 'password');
        mysql_select_db('db_name', $db);
        
        //check if there is a user with such login and password
        $res=mysql_query("SELECT * FROM users WHERE login='".$_POST['login']."'
            AND pass='".$_POST['pass']."'", $db);
        if(mysql_num_rows($res)!=1){    //such user doesn’t exist
            echo "Incorrect login and password";
        }
        else{    //user is found
            $_SESSION['login']=$_POST['login'];    //set login & pass
            $_SESSION['pass']=$_POST['pass'];
            Header("Location: protected.php");    // redirect him to protected.php
        }
        
        mysql_close();
    }
    ?>
    This sample of php login script describes easy way of access control with convenient method of saving user data in database. Here is another simple php login script that saves all inputted login and password in arrays $_POST and $_GET

    Code:
    <html>
        <head><title>Welcome to PHP</title></head>
        <body>
    <?php
        if ($login = $_POST["login"]) {
            echo "<b>Привет, login!</b>";
        }
    ?>
    <form method="post">
      your login:&nbsp;&nbsp;<input type="text" name="login"/><br/>
      <input type="submit" value="Enter"/>
    </form>
    </body>
    </html>
    Good luck.

  2. #2
    Administrator & Owner
    Array lankaentrepreneur's Avatar
    Join Date
    Jan 2010
    Location
    Earth
    Age
    28
    Posts
    208
    Country: Sri Lanka
    Post Thanks / Like
    Blog Entries
    8
    Rep Power
    10
    Follow lankaentrepreneur On Twitter Add lankaentrepreneur on Facebook Add lankaentrepreneur on Bebo Add lankaentrepreneur on MySpace Visit lankaentrepreneur's Youtube Channel Visit lankaentrepreneur's Vimeo Channel

    Default







    Great Work Penquin, keep it up
    l Srilankan Entrepreneurs Network & Internet Marketing Forum
    l
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
    |
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
    |
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
    |
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

    l Follow Me :
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

    l =============================================

  3. #3
    Advance Entrepreneur Array
    Join Date
    Jan 2010
    Posts
    105
    Post Thanks / Like
    Rep Power
    3

    Default hey







    What will be the names of the files? And how will I link second file to first? You haven't mentioned any link for first file in second file. Please mention file names too.

  4. #4
    Junior Entrepreneur Array
    Join Date
    Apr 2010
    Posts
    26
    Post Thanks / Like
    Rep Power
    0

    Default







    I am new to PHP .So please explain more about the coding .I thought that PHP is very difficult to learn.Is that right.

  5. #5
    Junior Entrepreneur Array
    Join Date
    May 2010
    Posts
    40
    Post Thanks / Like
    Rep Power
    0

    Default







    great info,i wil apply this into my new web design and it's very simple to do,just copy and paste right!!

  6. #6
    Junior Entrepreneur Array
    Join Date
    Sep 2010
    Location
    USA
    Posts
    10
    Post Thanks / Like
    Rep Power
    0

    Default







    Great work ! Keep it on ...

    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

  7. #7
    Junior Entrepreneur Array
    Join Date
    Oct 2010
    Location
    PPls says it Universe!!
    Posts
    91
    Post Thanks / Like
    Rep Power
    2

    Default







    Hy thanks for sharing....
    I really don,t have any idea about php but i want to learn php can you tell me how can and where can i learn php online

    Thanks in advance!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Linkbuilding Tips for Beginners
    By prettybomb2008 in forum Link Development
    Replies: 19
    Last Post: 04-21-2012, 06:00 AM
  2. HTML Login Page, PLEASE HELP
    By shnconger in forum Web Design & Blog Discussion
    Replies: 0
    Last Post: 11-09-2011, 11:14 PM
  3. Beginners’ Guide to SEO
    By aarisindia in forum Search Engine Optimization
    Replies: 3
    Last Post: 11-01-2011, 02:00 PM
  4. seo tips for Beginners
    By Qfjapipa in forum Search Engine Optimization
    Replies: 5
    Last Post: 11-01-2011, 01:51 PM
  5. Buying Domain for Beginners
    By prettybomb2008 in forum Domain Discussions
    Replies: 13
    Last Post: 07-03-2011, 10:55 PM

Bookmarks

Posting Permissions

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