Jump to content

[SOLVED] passing session error


Nazirul

Recommended Posts

hello

 

i've tried it to passing a value from a textbox into another page... it works on the same page bt when i try to use the session, its not work

 

this is from page A

 

$_SESSION['studentNom'] = $_POST['Student_Number'];	

 

and this is from page B to use that session..

 

echo $_SESSION['studentNom']; // echoing the session but it has no value...
$id = $_SESSION['studentNom'];

 

so my question is, what is the appropriate manner to retrieve the session...

 

and this is some of the php coding in page B

 

<?php


$db_name = "student";
$table_name = "student_information";

$connection = @mysql_connect("localhost", "root", "pass") or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());
echo $_SESSION['studentNom'];
id = $_SESSION['studentNom'];
$sql = "SELECT * FROM $table_name WHERE NO_PELAJAR = '$id'";
....

 

thanks  ;)

 

Link to comment
https://forums.phpfreaks.com/topic/154532-solved-passing-session-error/
Share on other sites

lol..

 

i really learn something today... thanks buddy..

 

whatever n whenever.. i have to put session_start(); when i want to use session on the page that use and will use the session

 

the error is due to i forgot to put the ';' ... very funny lol

 

...

 

but before this, when i use the session on the same page without the 'session_start();' ... it still display what i type in the textbox on the same page... so weird.. :D

 

thanks again everyone.. :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.