Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Can I use sessions to solve a problem?

Engaged ,
Feb 15, 2012 Feb 15, 2012

Copy link to clipboard

Copied

I have a set of three pages called say "pick", "edit" and "confirm". The edit page is on one of a set of 5 spry tabbed panels.The server is unix and the machine uses windows 64 bit and CS5.5.

Pick uses a drop down list to select an item to edit. It then sends the record index to the edit page where it is edited.

Edit then updates the page and sends the user to the confirm page where he told that the edit was OK and is given a link that takes him back to the edit page.

So far everything works fine - the record is edited and the user knows it. But he needs to be able to check it, and that's the problem..

While this link does send the user back to the previous page, it does not send any info as to which record it should pull out.

I have tried to store the value of the record index in a session, but just cannot get it to be available ion the confirm page.

As soon as I enter <?php session_start() ?> on line 1 of any page, I get the message :

Warning: Cannot modify header information - headers already sent on line 1  on the pick page and line  62 on the edit page as soon as a button is pressed, or, in the case of the edit page, as soon as live View is active.

This line is where the page is directed to the next page using a stock Dreamweaver udate record behaviour.:


  $updateGoTo = "editok.php";

  if (isset($_SERVER['QUERY_STRING'])) {

    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";

    $updateGoTo .= $_SERVER['QUERY_STRING'];

}header(sprintf("Location: %s", $updateGoTo)); // This is line 62.

I have checked all the lines for white space, made sure that the instruction is on line 1 and have no include files other than connection files, all with no white space. Matters not whether I put them before or after the session start instruction.

I even created a new page with just a form and a field to send and this gives the same message - this was not on a spry panel..

PHP ini has the path to sessions set up, and sessions are visible there.

I get the feeling that the tabbed panels could be part of the problem, as when the user lands on the edit page, he has to select the second panel, so some output must have been sent to the browser.and that would kill the session I think?

Is there a way of passing the info from page to page without using sessions?

TOPICS
Server side applications

Views

889
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 16, 2012 Feb 16, 2012

Copy link to clipboard

Copied

>Is there a way of passing the info from page to page without using sessions?

Sure, you can pass info in the querystring. But, never use the querystring if it will allow a user to access restricted content. For example, you don't want to allow a user to modify the querystring so that they can view content of another user.

>Warning: Cannot modify header information

I'm sure that can be resolved if you post the entire page code.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 16, 2012 Feb 16, 2012

Copy link to clipboard

Copied

Are you saving your document as UTF-8 with BOM headers?

If so, try to save it without BOM...

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 17, 2012 Feb 17, 2012

Copy link to clipboard

Copied

LATEST

Thanks Burak - I was aware of the bom problem.

Bregent - I think that I found the problem. I was using a set of 5 spry tabs with a form on each and trying to update them one at a time. To get to any of the forms, I had to open a tab, so I assume that the browser generated some output and that was why I had problems with the sessions.

So I found out how to set up the tabs within the same form, which meant that I could edit all 5 pages at one go, and only post them on the last one. I got the idea from a post on the spry forum which links to a page containing  code which does this at

http://www.soleproductions.com/oakley/tabform.php

With some slight modification, this gave me a better solution with no need for sessions.

This still left the problem of passing the edit page location to the confirm page. Its such a long time since I have used parameters that I had forgotten them.

However, a little modification to the update record server behaviour enabled me to pass the correct value from the $_POST array to the confirm page.

Like so:

From this:

$updateGoTo = "editok.php";

  if (isset($_SERVER['QUERY_STRING'])) {

    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";

    $updateGoTo .= $_SERVER['QUERY_STRING'];

}header(sprintf("Location: %s", $updateGoTo));

To this:

  $updateGoTo = "editok.php?pick=" . $_POST['club_index'] . "";

  if (isset($_SERVER['QUERY_STRING'])) {

    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";

    $updateGoTo .= $_SERVER['QUERY_STRING'];

  }

  header(sprintf("Location: %s", $updateGoTo));

}

Using this code there was no problem with "headers already sent."

None of the info is particularly sensitive.

Thanks for the interest.

Howard Walker

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines