954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Session problem

I've installed Apache2.2.4 & php5.2.3 in my windows xp, evry thing is going perfect but when I want to transfer a session variable to another form its not tranfering.......plz any body help me on this regard. will I have to configer any file....its urgent for me..

nil_gh_80
Junior Poster in Training
64 posts since Aug 2007
Reputation Points: 8
Solved Threads: 2
 

Maybe post some code? All I can do now is direct you to PHP's session page. http://nl3.php.net/manual/en/ref.session.php

Anonymusius
Posting Whiz in Training
238 posts since Aug 2006
Reputation Points: 129
Solved Threads: 11
 

thanx 4 response

nil_gh_80
Junior Poster in Training
64 posts since Aug 2007
Reputation Points: 8
Solved Threads: 2
 

try using session_start()

here is a quick example
Session example

Sabia
Newbie Poster
4 posts since Jul 2007
Reputation Points: 10
Solved Threads: 1
 
try using session_start()


You should put session_start() In each page in the first, and write a variable contains the session... EX:session_start();
$_SESSION['user']="NAME";
$Variable=$_SESSION['user'];


It's Easy

Pro2000
Posting Whiz
351 posts since Jun 2007
Reputation Points: 44
Solved Threads: 23
 

I have a page that shows job posings and the recordset contains the job title called Position
on my first page I start the session, name the session and give it the value of the recordset like this:

session_start();
$_SESSION['Position']= $row_rsposition['Position'];


on the next page, I once again start the session and echo it to the screen to test it like so:

session_start();
echo $_SESSION['Position'];

you can further assign it to values on the form like this:
(this is a checkbox element)
/>

for a text box use something like this:

JeniF
Junior Poster in Training
52 posts since Aug 2007
Reputation Points: 10
Solved Threads: 5
 

Now I've installed XAMPP but still facing problem on session:
e.g. file1.php

<?
session_start();
session_register("n");
<body><form action=file2.php method=post>
..........
<input type=text name=n>
<input type=submit value=submit>
</body>
?>


file2.php

<?
session_start();
session_register("n");

print"name=.$n";

?>


the value of "n" is not printing on file2.php ..................if there is anything wrong in this code, plz give me some correct one........

nil_gh_80
Junior Poster in Training
64 posts since Aug 2007
Reputation Points: 8
Solved Threads: 2
 

First off, the code you posted is not even valid code. You have php and html mixed in together and no end form tag to boot. Have you even attempted to run this code yourself?

As far as session, you have not set the value of 'n' in the session. In your code, 'n' is a post variable. If you want it in $_SESSION[] you need to set the value yourself. If you only need it the one time, then just read it from $_POST[]. If it needs to persist, set it in $_SESSION[].

It is fairly obvious that you are not reading any of the tutorial links that were posted, but just expecting people to write the code for you. You need to take the time to read and learn from the tutorials and php manual as well.

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

thanx for the suggestion......i got it.

nil_gh_80
Junior Poster in Training
64 posts since Aug 2007
Reputation Points: 8
Solved Threads: 2
 

Are you sure to have session_start(); at the first line of your page

jocbed60
Newbie Poster
1 post since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You