Page 1 of 1

Session coding question

Posted: Sat Apr 28, 2007 3:01 pm
by manton
Hello !

I have a problem with sessions. Please, check what is wrong with my code

page1 is a form

page2

Code: Select all

session_start();
$_SESSION['ses_kod'] = $_POST['txtkod'];
It works up to here, I get the data but when loading the page itself (a link that points to the page itself) data is lost.

Then I have a page 3

Code: Select all

<?php session_start();
?>
Here is the problem, I cannot retreive any data.

Thanks

Posted: Sat Apr 28, 2007 3:13 pm
by feyd
Did your computer refuse the cookie and/or not transfer the id via the URL?

Posted: Sat Apr 28, 2007 3:24 pm
by manton
It accepts cookies. My first page is a form and uses the method "post"

Posted: Sat Apr 28, 2007 3:30 pm
by nickvd
How are you retrieving the data on page 3? You didn't paste it...

Posted: Sat Apr 28, 2007 3:51 pm
by manton
ok..this is my entire page

Code: Select all

<?php session_start();
?>
<?php
	require_once('../Connections/palso.php');
$colname_Recordset1 = "-1";
if (isset($_SESSION['ses_kod'])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_SESSION['ses_kod'] : addslashes($_SESSION['ses_kod']);
}
mysql_select_db($database_palso, $palso);
$query_Recordset1 = sprintf("SELECT * FROM `data` WHERE SchoolCode = '%s'", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $palso) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7" />
<title>&#932;&#945;&#958;&#953;&#957;&#972;&#956;&#951;&#963;&#951; &#965;&#960;&#959;&#968;&#951;&#966;&#943;&#969;&#957; &#945;&#957;&#940; &#949;&#960;&#943;&#960;&#949;&#948;&#959;</title>
<link href="styles.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="print.css" media="print" />
</head>

<body>
<div id="container">
<div id="list">
<h4>&#923;&#921;&#931;&#932;&#913;</h4>

<form id="form1" name="form1" method="get" action="tickets.php">
<input class="nav" type="submit" name="Submit" value="&#917;&#956;&#966;&#940;&#957;&#953;&#963;&#951; " />
<p></p>

<table width="600" border="1">
  <tr>
    <td width="20">&nbsp;</td>
    <td width="140" class="fields"><a href="list.php">LevelDescription</a></td>
    <td width="140" class="fields"><a href="list_bin.php">BinSerialCode</a></td>
    <td width="300" class="fields"><a href="list_sur.php">Surname</a></td>
  </tr>
  <?php do { ?>
    <tr>
      <td class="calign">
        <input type="checkbox" name="checkbox[]" value="<?php echo $row_Recordset1['BinSerialCode']; ?>" />      </td>
      <td class="calign"><?php echo $row_Recordset1['LevelDescription']; ?></td>
      <td class="calign"><?php echo $row_Recordset1['BinSerialCode']; ?></td>
      <td><?php echo $row_Recordset1['Surname']; ?></td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</form>
</div>
</div>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

Posted: Sat Apr 28, 2007 4:29 pm
by nickvd
So that is the page that you are trying to retrieve the session data from?

I'm on my way out so I only scanned your code, but I didn't see anywhere in your code where you try to retrieve the session data...

That is page 3?

Posted: Sat Apr 28, 2007 4:35 pm
by manton
Yes, this is page 3.
I tried to use the same code I used on page 2 thar worked

Code: Select all

session_start();
$_SESSION['ses_kod'] = $_POST['txtkod'];
but it didnt work for page 3.

Please, have a look when u return home. I ll be waiting.
Thank u very much,
Martha