hi all,


i am not able to print the message which i taken in session variable
$_SESSION ="* Property details saved successfully"

i am posting all the values on the same page and redirected the header to get all the updated values back.

but when i use unset($_SESSION) after echoing this session variable it does not appear, but when i removed the unset($_SESSION) message is being appear.

i am not getting what is the problem in the source code
complete page source code is below

Please help me

Thanks.

<?php
/* check sesison */
require_once('chksession.php');
require_once('includes/dbconfig.php');
$rs1 = $db->fnSelect('tbl_hotel','*','id='.$_SESSION['pid']) or die('There is some technical problem');
/* get all the details of property */
?>
<?php
	/* update all the property details */
	if ($_POST['action']=='save') {
		/** check all the values those are required on the server side */
		require_once('includes/class/validation.class.php');
		$location     = htmlspecialchars(strip_tags($_POST['location_name']));
		$beach        = htmlspecialchars(strip_tags($_POST['beach']));
		$propertyname = htmlspecialchars(strip_tags($_POST['property_name']));
		$acc_type     = htmlspecialchars(strip_tags($_POST['acc_type']));
		$address      = htmlspecialchars(strip_tags($_POST['street_address']));
		$owner        = htmlspecialchars(strip_tags($_POST['owner']));
		$website_url  = htmlspecialchars(strip_tags($_POST['website_url']));
		$t = "NOW()";
		
		/* initialize obj object for validation */
		$obj = new PhpServerValidation();
		$obj->fnGetFields($location,'req','Location name is required');
		$obj->fnGetFields($propertyname,'req','Property name is required');
		$obj->fnGetFields($acc_type,'req','Accomodation Type is required');	
		$obj->fnGetFields($address,'req','Steet Address is required');	
		$obj->fnGetFields($owner,'req','Authority is required');	
		
		/* validate all the fields */
		$error = $obj->fnFieldsvalidation();
		
		/* if there is an error display it out */
		if (!empty($error)) {
			$error_msg = '<UL>'.$error.'</UL>';
		} 
		/* update all the fields */
		else {
			$loc = array();
			$loc = explode("::",$location);
			/* check if checkboxes values are preset */
			if ($_POST['chk']) {
				/* make a string of all the features */
				$fe = implode(",",$_POST['chk']);
			 } else {
				$fe = '';
			 }
			$fields = "name='$propertyname',location_zone='$loc[0]',location_area='$loc[1]',address='$address',beach='$beach',property_type  	='$acc_type',owner='$owner',features='$fe',date_time=$t";
			$condition = 'id='.$_SESSION['pid'];
			//update the values into table
			$outputupdate = $db->fnUpadte('tbl_hotel',$fields,$condition);
			if ($outputupdate) {
				$_SESSION['msg'] = "* property details saved successfully"
header('Location:property_details.php?pid='.$_SESSION['pid'].) ;
			}
		}
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Goaseahomes Owner Admin - <?php echo  $_SESSION['pname'] ?></title>
<link rel="stylesheet" type="text/css" href="css/theme.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="css/ie-sucks.css" />
<![endif]-->
<script>
	function chk() {
		var form = document.frmPropertyDetails;
		var error = "";
		if (form.property_name.value=="") error+="Please enter a property name\n";
		if (form.location_name.value=="") error+="Please select the location name of your property\n";
		if (form.acc_type.value=="") error+="Please select accomodation type of your peoperty\n";
		if (form.street_address.value=="") error+="Please enter the street address of your property\n";
		if (form.owner.value=="") error+="Please select authority\n"
		
		if(error !="") {
			alert(error);
			return false;
		}
		else {
			document.form.submit();
		}
	}
</script>
</head>

<body>
	<div id="container">
    	<?php include('includes/header.php'); ?>
        <div id="wrapper">
          <div id="content" style="border:1px solid #ccc;">
       			<div id="rightnow">
                    <h3 class="reallynow">
                        <span>Property Details</span>
                        <br />
                    </h3>
				    <p>Use this page to update your property details. </p>
				    <div class="usethis">Please note that any changes made will  take up to 15 minutes  to appear on Consumer sites. </div>
			  </div>
			  <form name="frmPropertyDetails" id="frmPropertyDetails" action="" method="post" onsubmit="return chk();" >
			  <input type="hidden" value="save" name="action" />
			  <?php if ($error_msg) {?>
                  <div class="error_message">* Please complete all required fields<?php echo $error_msg;unset($error_msg) ?></div>
                <?php } ?>
				  <?php
				  if (isset($_SESSION['msg'])){
					  echo '<div class="success_message">* Property details saved successfully<br/><span class="nos">Your property details have been saved. Make any additional changes below, or select another menu item from the left. </span></div>';
                                       unset($_SESSION['msg']);
				  }
				  ?>
                <table width="734" border="0" cellpadding="3" cellspacing="0" style="margin-top:10px;">
                  <tr>
                    <td height="32" colspan="3" valign="top"><strong>Location Details</strong> </td>
                  </tr>
                  <tr class="row0">
                    <td width="190" align="right">*Loation:</td>
                    <td width="313"><label>
					  <?php  $location = $db->fnSelect('tbl_hotel_location','*','status=1 order by id');?>
                      <select name="location_name" id="location_name" style="width:260px;">
						   <option value="">:: Select property location ::</option>
						 <?php if ($location) { foreach ($location as $key=>$loc) { ?>
						 	<?php  $fi = trim($loc['zone'].'::'.$loc['town']);
								   echo $fiedit = trim($rs1[0]['location_zone'].'::'.$rs1[0]['location_area']);	
							 ?>
						 	<option value="<?php echo $fi; ?>" <?php if($fi==$fiedit) { ?> selected="selected" <?php } ?>><?php echo $loc['zone'].'::'.$loc['town']; ?></option>
						 <?php }} ?>
					    </select>
                    </label></td>
                    <td width="213" align="right">&nbsp;</td>
                  </tr>
                  <tr>
                    <td align="right">Beach: </td>
                    <td><input name="beach" type="text" value="<?php echo $rs1[0]['beach']; ?>" size="39" maxlength="100" /></td>
                    <td align="right">Max 100 characters </td>
                  </tr>
                  <tr>
                    <td align="right">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td align="right">&nbsp;</td>
                  </tr>
                  <tr>
                    <td height="33" colspan="3" align="left" valign="top"><strong>Property Details </strong></td>
                  </tr>
                  <tr class="row0">
                    <td align="right">*Property Name: </td>
                    <td><input type="text" name="property_name" id="property_name"  size="50" value="<?php echo $rs1[0]['name']; ?>"/></td>
                    <td align="right">&nbsp;</td>
                  </tr>
                  <tr>
                    <td align="right">*Accomodation Type: </td>
                    <td>
					<select name="acc_type">
						  <option value="">:: Select accomodation type ::</option>
                          <option value="House" <?php if ($rs1[0]['property_type']=='House') { ?> selected="selected"
						  <?php } ?>>House</option>
						  <option value="Apartment" <?php if ($rs1[0]['property_type']=='Apartment') { ?> selected="selected"
						  <?php } ?>>Apartment</option>
						  <option value="Bed & Breakfast" <?php if ($rs1[0]['property_type']=='Bed & Breakfast') { ?> selected="selected"
						  <?php } ?>>Bed & Breakfast</option>
						  <option value="Hotel" <?php if ($rs1[0]['property_type']=='Hotel') { ?> selected="selected"
						  <?php } ?>>Hotel</option>
						  <option value="Cottage" <?php if ($rs1[0]['property_type']=='Cottage') { ?> selected="selected"
						  <?php } ?>>Cottage</option>                   
					</select></td>
                    <td align="right">&nbsp;</td>
                  </tr>
                  <tr class="row0">
                    <td align="right">*Street Address: </td>
                    <td><input type="text" name="street_address" id="street_address"  size="50" value="<?php echo $rs1[0]['address'] ?>"/></td>
                    <td align="right">Not displayed to public</td>
                  </tr>
                  <tr>
                    <td align="right">*Authority:</td>
                    <td>
						<select name="owner" id="owner" style="width:260px;">
                          <option value="">:: Select authority ::</option>
                          <option value="Owner" <?php if ($rs1[0]['owner']=='Owner') { ?> selected="selected"
						  <?php } ?>>Owner</option>
                          <option value="Tourism officer" <?php if ($rs1[0]['owner']=='Tourism officer') { ?> selected="selected"
						  <?php } ?>>Tourism officer</option>
                          <option value="Onsite Manager"  <?php if ($rs1[0]['owner']=='Onsite Manager') { ?> selected="selected"
						  <?php } ?>>Onsite Manager</option>
                          <option value="Real Estate Agent" <?php if ($rs1[0]['owner']=='Real Estate Agent') { ?> selected="selected"
						  <?php } ?>>Real Estate Agent</option>
                        </select>					</td>
                    <td align="right">&nbsp;</td>
                  </tr>
                  <tr class="row0">
                    <td align="right">Web Site: </td>
                    <td><input type="text" name="website_url" id="website_url"  size="50" value="<?php echo $rs1[0]['website']; ?>"/></td>
                    <td align="right">Not displayed to public</td>
                  </tr>
                  
                  <tr>
                    <td  height="33" colspan="3" align="left" valign="middle"><strong>Extra Details </strong></td>
                  </tr>
                  <tr>
                    <td  height="33" colspan="3" align="left" valign="top" class="td_feature">
					<table style="width:700px;" border='0' cellspacing='0' cellpadding='3'>
						<?php 
							$edit_fs = array();
							$edit_fs = explode(",",$rs1[0]['features']);
						?>
						<?php
							$features = $db->fnSelect('tbl_features','feature');
							$fi = count($features)/3;
							$j=0;
							
							for ($i=$j;$i<$fi;$i++) {
								$x = $j+1;
								$y = $j+2;
								$class = ($i%2==0) ?  'row0' : '';
								echo "<tr width='500' class=$class>";
								if (!empty($features[$j][0])) {
									if (in_array($features[$j][0],$edit_fs)) {
										echo "<td><input name='chk[]' type='checkbox' checked='checked' value='".$features[$j][0]."'/>&nbsp;".$features[$j][0]."</td>";
									} else {
										echo "<td><input name='chk[]' type='checkbox' value='".$features[$j][0]."' />&nbsp;".$features[$j][0]."</td>";
									}
								}
								if (!empty($features[$x][0])) {
									if (in_array($features[$x][0],$edit_fs)) {
										echo "<td><input name='chk[]' type='checkbox' checked='checked' value='".$features[$x][0]."'  />&nbsp;".$features[$x][0]."</td>";
									} else {
										echo "<td><input name='chk[]' type='checkbox' value='".$features[$x][0]."' />&nbsp;".$features[$x][0]."</td>";
									}	
								}
								if (!empty($features[$y][0])) {
									if (in_array($features[$y][0],$edit_fs)) {
										echo "<td><input name='chk[]' type='checkbox' checked='checked' value='".$features[$y][0]."'  />&nbsp;".$features[$y][0]."</td>";
									} else {
										echo "<td><input name='chk[]' type='checkbox' value='".$features[$y][0]."'  />&nbsp;".$features[$y][0]."</td>";
									}	
								}
								echo "</tr>";
								$j=$j+3;
							}
							
							?>	
							</table>							</td>
                  </tr>
                  <tr>
                    <td colspan="3" align="center">					</td>
                  </tr>
                  
                  <tr>
                    <td align="left"><label>
                      <input type="submit" name="Submit" value="save property details" />
                    </label></td>
                    <td>&nbsp;</td>
                    <td align="right">&nbsp;</td>
                  </tr>
                  <tr>
                    <td align="right">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td align="right">&nbsp;</td>
                  </tr>
                </table>
			</form>
          </div>
            <?php include("includes/sidebar.php"); ?>
      </div>
        <div id="footer">
        <div id="credits">
   		&copy;Copyright <a target="_blank" href="http://www.goaseahomes.com">Goaseahomes</a> all rights reserved
        </div>
        <br />

        </div>
</div>
</body>
</html>

its very natural, if you unset some variable using unset($var_name) function, its value disappears.so don't use it if you don't want to reset the variable

as i am taking message in the session variable so i need to unset it after message display so that it can not appear when i will come back from other pages as well.

its very natural, if you unset some variable using unset($var_name) function, its value disappears.so don't use it if you don't want to reset the variable

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.