Results 1 to 8 of 8

Thread: Login form?

  1. #1
    Join Date
    Oct 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Login form?

    how do i make a login and register form and when you login it shows you name that you are loged in with?

  2. #2
    Join Date
    Oct 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That's PHP. But if you just want a saved cookie (no register), then you can just use Javascript cookies.

  3. #3
    Join Date
    Oct 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    And how do i go by doing that?

  4. #4
    Join Date
    Oct 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well, if you don't use a register thing, you use PHP to set a cookie that has the name, then display it wherever you want, like Welcome, NAME! (logout|settings) or something like that. I can't teach you PHP, go learn it here: http://w3schools.com/php/default.asp

    For a register thing, it's the same thing, use a cookie to save that fact that you're logged in, but store the username and passwords in a database. That's mysql, and i think they teach some of that in the link.

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Javascript can't and won't be secure. It won't be security in any way nor would it help you store information about the user, create an account, etc.
    the only thing it could do is give the appearence of a login, which, unless it's just for fun, won't do you much good.

    PHP is fairly complex, so dive right in and get to it. It's not so bad to learn about.
    Basically... you need to use a database and store the user/(encrypted) password in there to compare to the values entered in a form.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Oct 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I did not create this post... but I am also in search of a secure way to do this. I just don't know where to get started, how do I learn what I need to know?

  7. #7
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    There is a way to do it with just PHP, but most people use a PHP/MySql database.

    You could save the register settings into a file:

    Code:
    <?php
    $filename = 'userfile.txt';
    $user = $_POST["user"];
    $pass = $_POST["pass"];
    $adduser = "User: $user\nPass: $pass\n\n";
    if (is_writable($filename)) {
    
       if (!$handle = fopen($filename, 'm')) {
             echo "Cannot open file ($filename)";
             exit;
       }
    
       if (fwrite($handle, $adduser) === FALSE) {
           echo "Cannot write to file ($filename)";
           exit;
       }
      
       echo "Task complete.";
      
       fclose($handle);
    
    } else {
       echo "Entry failed.";
    }
    ?>
    the html would be:

    Code:
    <form action="thefileabove.php">
    <input name="user">
    <br><input name="pass">
    <br><input type="submit">
    </form>
    And call it later
    Last edited by mburt; 10-19-2006 at 10:37 PM.
    - Mike

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    http://www.twey.co.uk/?q=loginscript is a pretty basic pre-made one. Requires PHP and MySQL.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •