4 Replies Latest reply on Oct 13, 2006 8:52 AM by quellgeist

    php $updateGoTo

    quellgeist
      Hello,
      In the following script the change of location works perfectly well:

      $updateGoTo = "liste.php?eigen='ja'&user='".$user."'";
      if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
      $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
      $updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));

      As soon as I add an echo command (see following example) the location is NOT changed.The echo is printed but instead of jumping to "liste,php" this page is refreshed.

      $updateGoTo = "liste.php?eigen='ja'&user='".$user."'";
      if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
      $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
      $updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
      echo $updateGoTo;}
      header(sprintf("Location: %s", $updateGoTo));

      Can anybody explain this phenomenon to me?
      Thanks.
      Bernhard
        • 1. Re: php $updateGoTo
          Level 7
          You can't send any output to the browser before the header() command,
          because once you do the raw HTTP header information (which should contain
          the redirect) is closed and cannot be reopened , so the redirect can't take
          place.

          Because you have the echo command sending output before the header()
          command, it stops the redirect from happening. Remove the echo and it will
          work fine.

          Gareth
          http://www.phploginsuite.co.uk/
          PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.


          • 2. Re: php $updateGoTo
            Level 1
            quellgeist,

            You know, you should post this question at Dynamic HTML Dreamwever discussion or DW Application Development.
            • 3. Re: php $updateGoTo
              Level 7
              Dynamic wouldn't be the correct place for it. But here or appdev will work
              fine.

              --
              Murray --- ICQ 71997575
              Adobe Community Expert
              (If you *MUST* email me, don't LAUGH when you do so!)
              ==================
              http://www.dreamweavermx-templates.com - Template Triage!
              http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
              http://www.dwfaq.com - DW FAQs, Tutorials & Resources
              http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
              ==================


              "Deaf Web Designer" <webforumsuser@macromedia.com> wrote in message
              news:ego6k0$rbn$1@forums.macromedia.com...
              > quellgeist,
              >
              > You know, you should post this question at Dynamic HTML Dreamwever
              > discussion or DW Application Development.


              • 4. Re: php $updateGoTo
                quellgeist Level 1
                Thank you for you prompt gareth,
                I have this problem now:
                In the following mysql update I want to to make sure that the correct date has been entered. So I added the marked "if" command which works OK. But the redirection at the end still doesn't work.

                if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form1")) {

                $date = explode ('.', $HTTP_POST_VARS['standarddatum']); $HTTP_POST_VARS['Geburtstag']=$date[2].'-'.$date[1].'-'.$date[0];

                if(!is_array($date) || count($date) != 3 || !checkdate($date[1], $date[0], $date[2]) || $jahr-$date[2] >60 || $jahr-$date[2] <15 )
                {$fehler=1; echo "<META HTTP-EQUIV=REFRESH CONTENT='0; URL=update3.php?standarddatum=".$HTTP_POST_VARS['standarddatum']."&user=".$user."&falsch= ".$fehler."&&id=".$HTTP_POST_VARS['id']."'>";}


                $updateSQL = sprintf("UPDATE bewerber SET Name=%s, Vorname=%s, Geburtstag=%s, Strasse=%s, Wohnort=%s, Vorbildung=%s, D=%s, E=%s, M=%s, KF=%s, MF=%s, wunsch1=%s, wunsch2=%s, wunsch3=%s, Entscheidung=%s, IP=%s WHERE id=%s",
                GetSQLValueString($HTTP_POST_VARS['Name'], "text"),
                GetSQLValueString($HTTP_POST_VARS['Vorname'], "text"),
                (...etc.)

                mysql_select_db($database_rgs, $rgs);
                $Result1 = mysql_query($updateSQL, $rgs) or die(mysql_error());

                $updateGoTo = "liste.php?eigen='ja'&user='".$user."'";
                if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
                $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
                $updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
                }
                header(sprintf("Location: %s", $updateGoTo));
                }

                Could you perhaps suggest any alternative way of checking this date format AND allow the redirect command to function properly. (Sorry, but I am not yet too familiar with these things and my boss insists that I try it out till I succeed :-(((()
                Thanks for any help.
                Bernhard