Login Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • werks
    New Member
    • Dec 2007
    • 218

    Login Form

    hi guy'z Im new in PHP could someone tell me how to create a Login form using PHP?

    --
    Kenneth
    "Better Than Yesterday"
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Originally posted by werks
    hi guy'z Im new in PHP could someone tell me how to create a Login form using PHP?

    --
    Kenneth
    "Better Than Yesterday"
    google is your friend ;)

    Comment

    • werks
      New Member
      • Dec 2007
      • 218

      #3
      Thanks for your advice..

      --
      Kenneth
      "Better Than Yesterday"

      Comment

      • harshmaul
        Recognized Expert Contributor
        • Jul 2007
        • 490

        #4
        Hi werks, you can check this link out...

        Creating a PHP CMS for administration

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          For the last time then, here we go again, a simple form
          [php]<?php
          session_start() ;
          // -------------------------------
          // check if form is submitted
          // -------------------------------
          $error = false;
          if (isset($_POST['_submit']) ) {
          if (isset($_POST['userid']) AND isset($_POST['password'])) {
          $uid = strip_tags($_PO ST['uid']);
          $psw = strip_tags($_PO ST['psw']);
          // ------------------------------------------------
          // Check passed username and password in database
          // ------------------------------------------------
          // ......
          // ..... connect to data base
          // ......
          // check existence of uid and psw in table
          $res = mysql_query("SE LECT * FROM authorized_user s WHERE userid='$uid' AND passwd=sha1('$p sw')")
          or die ("SELECT error: " . mysql_error());
          if (mysql_num_rows ($res) != 1) {
          $error = true;
          }
          else {
          // ------------------------------------------------
          // userid and psw valid, store userid in session
          // ------------------------------------------------
          $_SESSION['username'] = strip_tags($_PO ST['username']);
          // ...........
          // ===> continue processing valid user
          // ===> ...........
          }
          }
          else {
          // ------------------------------------------------
          // no userid and/or password specified, error
          // ------------------------------------------------
          $error = true;
          }
          }
          // ------------------------------------------------------
          // Display the login form (again)
          // ------------------------------------------------------
          print "<form name='authForm' method='POST' action='".$_SER VER['PHP_SELF']."'>";
          if ($error == true) {
          print "<p style='font-weight:bold;col or:red'>You have entered an invalid userid and/or password - try again</p>";
          }
          print "Username&nbsp; <input type='text' name='uid' value='$uid'> <br />";
          print "Password&nbsp; <input type='password' name='psw' value='$psw'> <br />";
          print '<input type="submit" name="login" value="Login" />';
          print '<input type="hidden" name="_submit" value="1"/>';
          print '</form>';
          ?>[/php]
          Ronald

          Comment

          • werks
            New Member
            • Dec 2007
            • 218

            #6
            Originally posted by harshmaul
            Hi werks, you can check this link out...

            Creating a PHP CMS for administration

            Thanks for the link..

            --
            Kenneth
            "Better Than Yesterday"

            Comment

            • werks
              New Member
              • Dec 2007
              • 218

              #7
              Thank you ronverdonk no hard feelings..

              --
              Kenneth
              "Better Than Yesterday"

              Comment

              • ronverdonk
                Recognized Expert Specialist
                • Jul 2006
                • 4259

                #8
                See you again.

                Ronald

                Comment

                • harshmaul
                  Recognized Expert Contributor
                  • Jul 2007
                  • 490

                  #9
                  No problem, I'm here to help :)

                  Comment

                  Working...