Hy, this is my first post on this forum i am begginer with sessions and i have some dificults. I will paste some of my code.
Every page where I use sessions i start with
Code: Select all
<? session_start()?>Code: Select all
<? include 'db.inc';
//connect to your database
if (!($connection = @ mysql_connect($hostName,$username,$password)))
die("Could not connect to database");
//specify database
if (!mysql_select_db($databaseName, $connection))
die("Unable to select database");
// Build SQL Query
$query = "select * from itworker";
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
// If we have no results, offer a google search as an alternative
if ($numrows == 0)
{
echo "<h4>Empty Table</h4>";
}
$result = mysql_query($query) or die("Couldn't execute query");
$count = 1 ;
// now you can display the results returned
while ($row= mysql_fetch_array($result))
{
$idworker = $row["workerID"];
$nameworker = $row["name"];
$lastnameworker = $row["lastname"];
echo "<a href=\"nalog.php?identworker=$idworker&imeeworker=$nameworker\">$count</a>";
echo ".) $nameworker $lastnameworker<br>" ;
$count++;
} ?>when I choose value from the first page everything is OK my choosen values are shown in my main page but when i go to the seccond page and choose value from the seccond page and return to the main page the values from the first page are missing only the values from the seccond are shown. I have made some test and I understand that in my session file the values from my first page are deleted. I made sessions variables in my main page like this :
Code: Select all
// sessijni promenlivi koi se od stranata worker.php
$_SESSION['idworker'] = $identworker; // values from first page
$_SESSION['imeworker'] = $imeeworker; //first page
// sessijni promenlivi koi se od stranata searchuser.php
$_SESSION['iduser'] = $siduser; // values from second page
$_SESSION['ime'] = $sime; // second page
$_SESSION['prezime'] = $sprezime; // second page
$_SESSION['telefon'] = $stelefon; // second page
$_SESSION['mobilen'] = $smobilen; // second page
$_SESSION['ulica'] = $sulica; // second pageAm i deleting session variales when i send values with href. And if I delete can you tall me how to remeber session variables directly in first page and second page when i have mysql_fetch_array($result).
Thanks !!!
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: