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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.