4 Replies Latest reply on Oct 28, 2008 12:10 PM by Newsgroup_User

    form login with database

    mattll Level 1
      Hi, I am trying to make a login so when you type a username and password into the input boxes in the form it checks the database then logins you in. I am having trouble with the code for this however and any help will be much appricated. Below is my code for the php file which is linked to the form on the index page.
      // Database Section

      // creates a new connection object
      $adoCon = new COM("ADODB.Connection");

      // the path to the folder holding this PHP script
      $sHere = dirname(__FILE__);

      // Get the data passed from the form
      $susername = $_POST['username'];
      $spassword = $_POST['password'];

      // opens the connection using a standard Access connection string
      $adoCon->Open("Provider=Microsoft.ACE.OLEDB.12.0;
      Data Source=$sHere/intermed.accdb");

      $sSQL= "SELECT * FROM members WHERE
      username = '$susername' and password = '$spassword'";

      $rsMain = $adoCon->Execute($sSQL);

      IF ($rsMain = $adoCon)

      Then

      header ("location: loggedin.htm")

      thanks for looking.
        • 1. Re: form login with database
          Level 7
          mattll posted in macromedia.dreamweaver:

          > IF ($rsMain = $adoCon)
          >
          > Then
          >
          > header ("location: loggedin.htm")

          Is this PHP? If so, then perhaps:

          if ($rsMain = $adoCon) {
          header ("location: loggedin.htm");
          exit;
          }

          Though you should probably use a full URL for the header() location.




          --
          Mark A. Boyd
          Keep-On-Learnin' :)
          • 2. Re: form login with database
            Level 7

            >
            > if ($rsMain = $adoCon) {
            > header ("location: loggedin.htm");
            > exit;
            > }

            Shouldn't this be

            if ($rsMain == $adoCon) {
            header ("location: loggedin.htm");
            exit;
            }

            If I am not mistaken, $rsMain = $adoCon sets $rsMain equal to $adoCon.

            $rsMain == $adoCon compares the two variables, assuming that is what you
            were after.

            Harvey
            • 3. Re: form login with database
              mattll Level 1
              hi, thanks for the replys will get back to you later after I have tried your suggestions
              • 4. Re: form login with database
                Level 7
                eclipsme posted in macromedia.dreamweaver:

                > Mark A. Boyd posted in macromedia.dreamweaver:
                >>
                >> if ($rsMain = $adoCon) {
                >> header ("location: loggedin.htm");
                >> exit;
                >> }
                >
                > Shouldn't this be
                >
                > if ($rsMain == $adoCon) {
                > header ("location: loggedin.htm");
                > exit;
                > }
                >
                > If I am not mistaken, $rsMain = $adoCon sets $rsMain equal to
                > $adoCon.
                >
                > $rsMain == $adoCon compares the two variables, assuming that is
                > what you were after.

                Absolutely correct!

                That and missing semicolons get me way too often.


                --
                Mark A. Boyd
                Keep-On-Learnin' :)