how to use session()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

nishmgopal
Forum Contributor
Posts: 101
Joined: Tue Mar 03, 2009 9:38 am

Re: how to use session()

Post by nishmgopal »

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /disks/diskh/zco/conmg/public_html/go.php on line 12
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: how to use session()

Post by susrisha »

dont know how but i got it sorted with my editor

Code: Select all

 
session_start();
if(isset($_POST['job']))
 {
 echo "post value assigned to job is ".$_POST['job'];
 
 
  $_SESSION['job']=$_POST['job'];
 
  echo "SESSION VALUE ASSIGNED is ".$_SESSION['job'];
  }
  else
  {
  echo "POST VALUE NOT ASSIGNED TO JOB";
 }
 
nishmgopal
Forum Contributor
Posts: 101
Joined: Tue Mar 03, 2009 9:38 am

Re: how to use session()

Post by nishmgopal »

Right that worked now. And I got the following output:

POST VALUE NOT ASSIGNED TO JOB

and the code you gave me to put on page2 is returning the below error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /disks/diskh/zco/conmg/public_html/find10a.php on line 65

The Code I have for page2 is:

Code: Select all

 
<?php
 
 session_start();
 if(!isset($_SESSION['job']))
 {
 echo "job value is not set";
 }
 else
 {
 echo "JOB Value is set to $_SESSION['job']";
 }
 ?>
 
 
 
 
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: how to use session()

Post by susrisha »

Code: Select all

 
//page2 code
 session_start();
 if(!isset($_SESSION['job']))
 {
 echo "job value is not set";
 }
 else
 {
 echo "JOB Value is set to". $_SESSION['job'];
 }
 
And in the form that you want to send the data.. i think in page1.php

Code: Select all

 
 
<form action="go.php" method="post">
 
nishmgopal
Forum Contributor
Posts: 101
Joined: Tue Mar 03, 2009 9:38 am

Re: how to use session()

Post by nishmgopal »

Thank you so much! It finnaly works!!

I cannot thank you enough, I have been struggling with this for far to long.

:)
Post Reply