4 Replies Latest reply on Sep 4, 2008 12:03 PM by Newsgroup_User

    Problem with Log in User dialogue box

    smiffy47 Level 1
      I have been trying to set up a simple login page with the use of the Server Behaviours on DWMX2004.
      I can get it to make a page with the ability to check username(already input into the form from a database) and password, and redirect to the next page. However the problem comes when I try to defne a parameter to be passed on to the next page. Then it wites code that results in a browser error message before the login page is even loaded. When I use the "parameter" addition on the "Log in User" dialogue box DW really gets its knickers in a twist and produces code where the code gets confused with the comment, and even after seperating them fails to operate. Here is the offending section as produced by DW:

      Can someone point out what changes are required to get the page to load and the value of "organ" passed on to next page after submission of the password, please? Thanks.
        • 1. Re: Problem with Log in User dialogue box
          Level 7
          smiffy47 posted in macromedia.dreamweaver:

          > Can someone point out what changes are required to get the page
          > to load and the value of "organ" passed on to next page after
          > submission of the password, please? Thanks.
          >
          Try removing all those external <?php ?> in that block of code that is
          already inside those tags.

          if (isset($_POST['cel_org'])) {
          $loginUsername=$_POST['cel_org'];
          $password=$_POST['cel_pw'];
          $MM_fldUserAuthorization = "";
          $MM_redirectLoginSuccess =
          "../org_changechoice.php?organ=$row_rstLog['cel_org']";
          $MM_redirectLoginFailed
          ="login_park.php?organ=$row_rstLog['cel_org']";
          $MM_redirecttoReferrer = false;
          mysql_select_db($database_tormented3, $tormented3);
          etc...


          --
          Mark A. Boyd
          Keep-On-Learnin' :)
          • 2. Re: Problem with Log in User dialogue box
            Level 7
            Mark A. Boyd posted in macromedia.dreamweaver:

            > smiffy47 posted in macromedia.dreamweaver:
            >
            >> Can someone point out what changes are required to get the page
            >> to load and the value of "organ" passed on to next page after
            >> submission of the password, please? Thanks.
            >>
            > Try removing all those external <?php ?> in that block of code
            > that is already inside those tags.

            That was supposed to be extra, not external:

            Try removing all those extra <?php ?> in that block of code that is
            already inside those tags.
            >
            > if (isset($_POST['cel_org'])) {
            > $loginUsername=$_POST['cel_org'];
            > $password=$_POST['cel_pw'];
            > $MM_fldUserAuthorization = "";
            > $MM_redirectLoginSuccess =
            > "../org_changechoice.php?organ=$row_rstLog['cel_org']";
            > $MM_redirectLoginFailed
            > ="login_park.php?organ=$row_rstLog['cel_org']";
            > $MM_redirecttoReferrer = false;
            > mysql_select_db($database_tormented3, $tormented3);
            > etc...
            >
            >



            --
            Mark A. Boyd
            Keep-On-Learnin' :)
            • 3. Problem with Log in User dialogue box
              smiffy47 Level 1
              Thanks Mark.
              No that doesn't help.
              Frustratingly I seem to be going backwards! Yesterday DW wrote me code that at least redirected me to a chosen
              page as a result of my completion of the "Log in User" dialogue box, even if it would not do so when I specified a
              parameter. Today I have tried recreating that small sucess and the page fails to redirect at all, simply representing
              itself with empty text fields.
              I guess I better start with overcoming this issue before trying to deal with the parameter one.
              The code DW provides for the simple redirect is

              if (isset($_POST['cel_org'])) {
              $loginUsername=$_POST['cel_org'];
              $password=$_POST['cel_pw'];
              $MM_fldUserAuthorization = "";
              $MM_redirectLoginSuccess = "../org_changechoice.php";
              $MM_redirectLoginFailed = "../org_list.php";
              $MM_redirecttoReferrer = false;
              mysql_select_db($database_tormented3, $tormented3);

              $LoginRS__query=sprintf("SELECT cel_org, cel_pw FROM cel_contents WHERE cel_org='%s' AND cel_pw='%s'",
              get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));

              $LoginRS = mysql_query($LoginRS__query, $tormented3) or die(mysql_error());
              $loginFoundUser = mysql_num_rows($LoginRS);
              if ($loginFoundUser) {
              $loginStrGroup = "";

              //declare two session variables and assign them
              $GLOBALS['MM_Username'] = $loginUsername;
              $GLOBALS['MM_UserGroup'] = $loginStrGroup;

              //register the session variables
              session_register("MM_Username");
              session_register("MM_UserGroup");

              if (isset($_SESSION['PrevUrl']) && false) {
              $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
              }
              header("Location: " . $MM_redirectLoginSuccess );
              }
              else {
              header("Location: ". $MM_redirectLoginFailed );
              }
              }
              ?>

              It gives rise to the url:
              http://localhost/torment_new/up_content/login/login.php?accesscheck=%2Ftorment_new%2Fup_co ntent%2Forg_changechoice.php

              whereas I am hoping for url
              http://localhost/torment_new/up_content/org_changechoice.php

              Can you see why I am getting this output?

              Thanks for taking an interest.
              • 4. Re: Problem with Log in User dialogue box
                Level 7
                smiffy47 posted in macromedia.dreamweaver:

                > Thanks Mark.
                > No that doesn't help.
                [...]

                Fair notice: I haven't used DW's built-in behaviors for anything
                related to database or PHP.

                >
                > if (isset($_POST['cel_org'])) {
                > $loginUsername=$_POST['cel_org'];
                > $password=$_POST['cel_pw'];
                > $MM_fldUserAuthorization = "";
                > $MM_redirectLoginSuccess = "../org_changechoice.php";
                > $MM_redirectLoginFailed = "../org_list.php";
                > $MM_redirecttoReferrer = false;
                > mysql_select_db($database_tormented3, $tormented3);
                >
                > $LoginRS__query=sprintf("SELECT cel_org, cel_pw FROM
                > cel_contents WHERE
                > cel_org='%s' AND cel_pw='%s'",
                > get_magic_quotes_gpc() ? $loginUsername :
                > addslashes($loginUsername),
                > get_magic_quotes_gpc() ? $password : addslashes($password));

                Dreamweaver writes that? Since you're using MySQL, I would convert that
                to use mysql_real_escape_string() instead of addslashes(). Likewise for
                wherever your INSERT call may be.

                http://us.php.net/manual/en/function.mysql-real-escape-string.php

                > $LoginRS = mysql_query($LoginRS__query, $tormented3) or
                > die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS);
                > if ($loginFoundUser) {
                > $loginStrGroup = "";
                >
                > //declare two session variables and assign them
                > $GLOBALS['MM_Username'] = $loginUsername;
                > $GLOBALS['MM_UserGroup'] = $loginStrGroup;
                >
                > //register the session variables
                > session_register("MM_Username");
                > session_register("MM_UserGroup");

                That is out of date. As long as you have session_start(); at the very
                beginning of your script, you can use:
                $_SESSION['MM_Username'] = $loginUsername;
                $_SESSION['MM_UserGroup'] = $loginStrGroup;

                And, unless the script requires it somewhere else, I would scrap those
                $GLOBALS['...']=whatever lines.

                > if (isset($_SESSION['PrevUrl']) && false) {
                > $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
                > }
                > header("Location: " . $MM_redirectLoginSuccess );
                > }
                > else {
                > header("Location: ". $MM_redirectLoginFailed );
                > }
                > }
                > ?>

                You should use a full URL for header().
                http://us.php.net/header

                For portability, you can utilize $_SERVER['HTTP_HOST']. Something like:

                $myHost = " http://{$_SERVER['HTTP_HOST'
                $MM_redirectLoginSuccess = "$myHost/org_changechoice.php";
                $redirectLoginFailed = "$myHost/org_list.php";

                (adjust for proper path if needed)

                > It gives rise to the url:
                >
                > http://localhost/torment_new/up_content/login/login.php?accesscheck
                > =%2Ftorment_n ew%2Fup_content%2Forg_changechoice.php
                >
                > whereas I am hoping for url
                > http://localhost/torment_new/up_content/org_changechoice.php
                >
                > Can you see why I am getting this output?

                No. I don't see where any parameters are getting appended to those
                location variables at all.

                As long as you're testing on your dev machine (localhost), set your
                php.ini file to show all errors.

                error_reporting = E_ALL
                display_errors = On


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