How to display Session values in php with dynamic html?

<?php                            
       session_start();
       echo "<b>Start Date:</b>$_SESSION['Date']<br />";
       echo "<b>Venue:</b>$_SESSION['address']<br />";
       echo "<b>Church Name: </b>$_SESSION['ChurchLead']<br />";
       echo "<b>Course Type </b>$_SESSION['coursename']<br />";
       echo "<b>Participants: </b>$_POST['NumbPart']<br />";
       echo "<b> Latitude: </b>$_SESSION['lat']<br />";
       echo "<b> Longitude: </b>$_SESSION['long']<br />";
?>

Is this a correct way of displaying Session values in php? I am getting blank values.

Answers


try this ,this is not better????? simple & easy read

<?php
   session_start();
?>
   <b>Start Date:</b><?=$_SESSION['Date'];?><br />
   <b>Venue:</b><?=$_SESSION['address'];?><br />
   <b>Church Name: </b><?=$_SESSION['ChurchLead'];?><br />
   <b>Course Type </b><?=$_SESSION['coursename'];?><br />
   <b>Participants: </b><?=$_POST['NumbPart'];?><br />
   <b> Latitude: </b><?=$_SESSION['lat'];?><br />
   <b> Longitude: </b><?=$_SESSION['long'];?><br />

To display the value from an array like that as string sub, you need to use {} around it in the string. For example:

echo "<b> Latitude: </b>$_SESSION['lat']<br />";

becomes

echo "<b> Latitude: </b>{$_SESSION['lat']}<br />";

This applies to instances where you are trying to access an array member, or accessing an object member (such as myObj->foo)

NOTE: I am operating under the assumption that your session array is completely valid.


First, change all lines to:

  echo "<b>MyVar:</b>".$_SESSION['myVar']."<br />";

Now, unless you have set the variable $_SESSION['MyVar'], you'll get blank output.


Need Your Help

How To Hide web.config appsetting params while using GIT and WebDeploy publish

visual-studio github web-config webdeploy web.config-transform

I'm struggling with finding a good way not to check my secret passwords into my web.config.production type files (the ones that get transformed when Web Deploy publish is done). my workflow is tha...

Fetch the title of map dropped pin via MKPointAnnotation

ios dictionary title pins mkpointannotation

I need to know how to fetch the title of a dropped pin. I have multiple dropped pins on the map, when the pin is tabbed I want to fetch the title to pass to prepareForSegue. I use this statement "let