Posting behavior??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shelly

    Posting behavior??

    I am a little puzzled by the sequence of events. Please help me out.

    I have page a.php. There is a button of type "submit" and name
    "submit". I do an

    if (isset($_POST['submit'])) {....}

    I enter the braces. Inside the braces I have a

    header("Locatio n: b.php");

    Now here is the thing. What happens is that the a.php seems to get
    reexecuted, and since it now fails on a fopen in a.php, the thing never gets
    to b.php. Initially I pass in to a.php parameters that enables it to find
    the file that it needs to open and read. However, now I am leaving a,php so
    why is a.php reexecuted? I came across this behavior before when I needed
    to pass a variable that was defined in the page. The called page couldn't
    get it. I solved this by setting a hidden variable in the calling page to
    that value and passing the value of the hidden variable in the url string.

    Also, what is the very best way of leaving a page and returning to the
    calling page? Right now I have been naming the calling page in the called
    page, but that is a bad hack. There has to be a better way. I looked at
    things like PrevUrl and didn't understand it.

    Thanks,
    Shelly


  • Shelly

    #2
    Re: Posting behavior??

    I took out the wordwrap on the sending side and I still get 16 (I counted
    now) spaces before the first character. After that it is fine. When I went
    to cut and paste to here, it looked like only one character.

    Here is an example:

    I am going to type this so that it has word wrap and will also have
    new paragraphs. It takes time to compose this so I amd going to
    simply cut and paste.

    So I did a $message = substr($message , 1);

    What happened was that the "I" at the beginning disappeared and it now had
    17 spaces (since the first in the text is also a space).

    Now 16 is a curious number (2 bytes), so I suspect something is going on
    with the first two bytes that are invisible to a substr(), but show up in an
    echo.

    Anyone?

    Shelly

    "Shelly" <sheldonlg.news @asap-consult.com> wrote in message
    news:1p6dnZPckf lwkELfRVn-uA@comcast.com. ..[color=blue]
    >I am a little puzzled by the sequence of events. Please help me out.
    >
    > I have page a.php. There is a button of type "submit" and name
    > "submit". I do an
    >
    > if (isset($_POST['submit'])) {....}
    >
    > I enter the braces. Inside the braces I have a
    >
    > header("Locatio n: b.php");
    >
    > Now here is the thing. What happens is that the a.php seems to get
    > reexecuted, and since it now fails on a fopen in a.php, the thing never
    > gets to b.php. Initially I pass in to a.php parameters that enables it to
    > find the file that it needs to open and read. However, now I am leaving
    > a,php so why is a.php reexecuted? I came across this behavior before when
    > I needed to pass a variable that was defined in the page. The called page
    > couldn't get it. I solved this by setting a hidden variable in the
    > calling page to that value and passing the value of the hidden variable in
    > the url string.
    >
    > Also, what is the very best way of leaving a page and returning to the
    > calling page? Right now I have been naming the calling page in the called
    > page, but that is a bad hack. There has to be a better way. I looked at
    > things like PrevUrl and didn't understand it.
    >
    > Thanks,
    > Shelly
    >[/color]


    Comment

    • Shelly

      #3
      Re: Posting behavior??

      I also tried file_get_conten ts() and got the same effect.

      Shelly

      "Shelly" <sheldonlg.news @asap-consult.com> wrote in message
      news:yYWdnUI4BZ UfiELfRVn-gA@comcast.com. ..[color=blue]
      >I took out the wordwrap on the sending side and I still get 16 (I counted
      >now) spaces before the first character. After that it is fine. When I
      >went to cut and paste to here, it looked like only one character.
      >
      > Here is an example:
      >
      > I am going to type this so that it has word wrap and will also have
      > new paragraphs. It takes time to compose this so I amd going to
      > simply cut and paste.
      >
      > So I did a $message = substr($message , 1);
      >
      > What happened was that the "I" at the beginning disappeared and it now had
      > 17 spaces (since the first in the text is also a space).
      >
      > Now 16 is a curious number (2 bytes), so I suspect something is going on
      > with the first two bytes that are invisible to a substr(), but show up in
      > an echo.
      >
      > Anyone?
      >
      > Shelly
      >
      > "Shelly" <sheldonlg.news @asap-consult.com> wrote in message
      > news:1p6dnZPckf lwkELfRVn-uA@comcast.com. ..[color=green]
      >>I am a little puzzled by the sequence of events. Please help me out.
      >>
      >> I have page a.php. There is a button of type "submit" and name
      >> "submit". I do an
      >>
      >> if (isset($_POST['submit'])) {....}
      >>
      >> I enter the braces. Inside the braces I have a
      >>
      >> header("Locatio n: b.php");
      >>
      >> Now here is the thing. What happens is that the a.php seems to get
      >> reexecuted, and since it now fails on a fopen in a.php, the thing never
      >> gets to b.php. Initially I pass in to a.php parameters that enables it
      >> to find the file that it needs to open and read. However, now I am
      >> leaving a,php so why is a.php reexecuted? I came across this behavior
      >> before when I needed to pass a variable that was defined in the page.
      >> The called page couldn't get it. I solved this by setting a hidden
      >> variable in the calling page to that value and passing the value of the
      >> hidden variable in the url string.
      >>
      >> Also, what is the very best way of leaving a page and returning to the
      >> calling page? Right now I have been naming the calling page in the
      >> called page, but that is a bad hack. There has to be a better way. I
      >> looked at things like PrevUrl and didn't understand it.
      >>
      >> Thanks,
      >> Shelly
      >>[/color]
      >
      >[/color]


      Comment

      • Ken Robinson

        #4
        Re: Posting behavior??



        Shelly wrote:[color=blue]
        > I am a little puzzled by the sequence of events. Please help me out.
        >
        > I have page a.php. There is a button of type "submit" and name
        > "submit". I do an
        >
        > if (isset($_POST['submit'])) {....}
        >
        > I enter the braces. Inside the braces I have a
        >
        > header("Locatio n: b.php");
        >
        > Now here is the thing. What happens is that the a.php seems to get
        > reexecuted, and since it now fails on a fopen in a.php, the thing never gets[/color]

        Can you post your code or enough of the code so we can see the problem.
        Without seeing the program flow, it is hard to determine where the
        problem lies.

        Ken

        Comment

        • Shelly

          #5
          Re: Posting behavior??


          "Ken Robinson" <kenrbnsn@rbnsn .com> wrote in message
          news:1121918986 .319055.207170@ z14g2000cwz.goo glegroups.com.. .[color=blue]
          >
          >
          > Shelly wrote:[color=green]
          >> I am a little puzzled by the sequence of events. Please help me out.
          >>
          >> I have page a.php. There is a button of type "submit" and name
          >> "submit". I do an
          >>
          >> if (isset($_POST['submit'])) {....}
          >>
          >> I enter the braces. Inside the braces I have a
          >>
          >> header("Locatio n: b.php");
          >>
          >> Now here is the thing. What happens is that the a.php seems to get
          >> reexecuted, and since it now fails on a fopen in a.php, the thing never
          >> gets[/color]
          >
          > Can you post your code or enough of the code so we can see the problem.
          > Without seeing the program flow, it is hard to determine where the
          > problem lies.
          >
          > Ken
          >[/color]

          <?php
          require_once('C onnections/ssLogin.php');
          session_start() ;
          $list_start = $_GET['liststart'];
          $i = $_GET['row'];
          $dbVal = $_SESSION['mail_list'];
          $from = $dbVal[$i]['sender'];
          $subj = $dbVal[$i]['subject'];
          $filename = $dbVal[$i]['filename'] . ".txt";
          $message = file_get_conten ts("mail_files/" . $filename);
          if (isset($_POST['submit'])) {
          if ($_POST['submit'] == "Reply"){
          $from = $_POST['SendTo'];
          $sendto = $_POST['From'];
          $subject = "Re: " . $_POST['Subject'];
          } else if ($_POST['submit'] == "Delete"){
          } else if ($_POST['submit'] == "Cancel"){
          }
          header("Locatio n: ssListMail.php? liststart=" . $list_start_poi nt); .
          ====
          html stuff with:
          <input type="submit" name="submit" value="Cancel">

          When I click the "Cancel" button, it tries to re-execute the page and gives
          me:

          Warning: file_get_conten ts(mail_files/.txt): failed to open stream: No such
          file or directory in /home/virtual/site23/fst/var/www/html/ssReadMail.php on
          line 10

          The first time in it read the filename and put the result in $message. My
          question is why is it running the page on submit rather than going to
          ssListMail.php.

          Shelly


          Comment

          • Shelly

            #6
            Re: Posting behavior??

            I moved the file_get_conten ts() to after the if(isset( stuff and now it
            goes where it should. However, why is is reexecuted? Is ir automatic so
            that it will then "see" the if(isset( code? It isn't stored anywhere? I
            guess that makes sense. What I will do from now on is handle things that
            way. So, it re=executes without passing parameters. Thnat is why the
            hidden variables are needed if they are needed in the if(isset( submit
            testing.

            Shelly

            "Shelly" <sheldonlg.news @asap-consult.com> wrote in message
            news:9PSdnb9-LLYiGELfRVn-vA@comcast.com. ..[color=blue]
            >
            > "Ken Robinson" <kenrbnsn@rbnsn .com> wrote in message
            > news:1121918986 .319055.207170@ z14g2000cwz.goo glegroups.com.. .[color=green]
            >>
            >>
            >> Shelly wrote:[color=darkred]
            >>> I am a little puzzled by the sequence of events. Please help me out.
            >>>
            >>> I have page a.php. There is a button of type "submit" and name
            >>> "submit". I do an
            >>>
            >>> if (isset($_POST['submit'])) {....}
            >>>
            >>> I enter the braces. Inside the braces I have a
            >>>
            >>> header("Locatio n: b.php");
            >>>
            >>> Now here is the thing. What happens is that the a.php seems to get
            >>> reexecuted, and since it now fails on a fopen in a.php, the thing never
            >>> gets[/color]
            >>
            >> Can you post your code or enough of the code so we can see the problem.
            >> Without seeing the program flow, it is hard to determine where the
            >> problem lies.
            >>
            >> Ken
            >>[/color]
            >
            > <?php
            > require_once('C onnections/ssLogin.php');
            > session_start() ;
            > $list_start = $_GET['liststart'];
            > $i = $_GET['row'];
            > $dbVal = $_SESSION['mail_list'];
            > $from = $dbVal[$i]['sender'];
            > $subj = $dbVal[$i]['subject'];
            > $filename = $dbVal[$i]['filename'] . ".txt";
            > $message = file_get_conten ts("mail_files/" . $filename);
            > if (isset($_POST['submit'])) {
            > if ($_POST['submit'] == "Reply"){
            > $from = $_POST['SendTo'];
            > $sendto = $_POST['From'];
            > $subject = "Re: " . $_POST['Subject'];
            > } else if ($_POST['submit'] == "Delete"){
            > } else if ($_POST['submit'] == "Cancel"){
            > }
            > header("Locatio n: ssListMail.php? liststart=" . $list_start_poi nt); .
            > ====
            > html stuff with:
            > <input type="submit" name="submit" value="Cancel">
            >
            > When I click the "Cancel" button, it tries to re-execute the page and
            > gives me:
            >
            > Warning: file_get_conten ts(mail_files/.txt): failed to open stream: No
            > such file or directory in
            > /home/virtual/site23/fst/var/www/html/ssReadMail.php on line 10
            >
            > The first time in it read the filename and put the result in $message. My
            > question is why is it running the page on submit rather than going to
            > ssListMail.php.
            >
            > Shelly
            >[/color]


            Comment

            • Jerry Stuckle

              #7
              Re: Posting behavior??

              Shelly wrote:[color=blue]
              > "Ken Robinson" <kenrbnsn@rbnsn .com> wrote in message
              > news:1121918986 .319055.207170@ z14g2000cwz.goo glegroups.com.. .
              >[color=green]
              >>
              >>Shelly wrote:
              >>[color=darkred]
              >>>I am a little puzzled by the sequence of events. Please help me out.
              >>>
              >>>I have page a.php. There is a button of type "submit" and name
              >>>"submit". I do an
              >>>
              >>>if (isset($_POST['submit'])) {....}
              >>>
              >>>I enter the braces. Inside the braces I have a
              >>>
              >>>header("Loca tion: b.php");
              >>>
              >>>Now here is the thing. What happens is that the a.php seems to get
              >>>reexecuted , and since it now fails on a fopen in a.php, the thing never
              >>>gets[/color]
              >>
              >>Can you post your code or enough of the code so we can see the problem.
              >>Without seeing the program flow, it is hard to determine where the
              >>problem lies.
              >>
              >>Ken
              >>[/color]
              >
              >
              > <?php
              > require_once('C onnections/ssLogin.php');
              > session_start() ;
              > $list_start = $_GET['liststart'];
              > $i = $_GET['row'];
              > $dbVal = $_SESSION['mail_list'];
              > $from = $dbVal[$i]['sender'];
              > $subj = $dbVal[$i]['subject'];
              > $filename = $dbVal[$i]['filename'] . ".txt";
              > $message = file_get_conten ts("mail_files/" . $filename);
              > if (isset($_POST['submit'])) {
              > if ($_POST['submit'] == "Reply"){
              > $from = $_POST['SendTo'];
              > $sendto = $_POST['From'];
              > $subject = "Re: " . $_POST['Subject'];
              > } else if ($_POST['submit'] == "Delete"){
              > } else if ($_POST['submit'] == "Cancel"){
              > }
              > header("Locatio n: ssListMail.php? liststart=" . $list_start_poi nt); .
              > ====
              > html stuff with:
              > <input type="submit" name="submit" value="Cancel">
              >
              > When I click the "Cancel" button, it tries to re-execute the page and gives
              > me:
              >
              > Warning: file_get_conten ts(mail_files/.txt): failed to open stream: No such
              > file or directory in /home/virtual/site23/fst/var/www/html/ssReadMail.php on
              > line 10
              >
              > The first time in it read the filename and put the result in $message. My
              > question is why is it running the page on submit rather than going to
              > ssListMail.php.
              >
              > Shelly
              >
              >[/color]

              Call exit() after your header() call. Otherwise all you do is set the header
              and continue processing.


              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              Working...