I need a help for a long Time !!!

Discussion in 'PHP' started by mahdi_fci3, Aug 30, 2010.

  1. #1
    Hi all,
    I have a problem for a long Time, and I need a help.
    My problem is I have created the folllowing code, when I insert new record and I press the back buttom of the browser to back my menu I get error message from the browser:"your web page has expired", so please help me as soon as possible
    
    <?php 
    
    session_start() ;
    include("../session.php");
    getSession($_SESSION['adminUser']);
    include("../conection.php");
    
    if($_POST['ADD'] !='' && $_POST['Name'] !='' ){
    			$Name =htmlentities(mysql_real_escape_string($_POST[Name]));			
    			$Address =htmlentities(mysql_real_escape_string($_POST[Address]));	
    			$Day =$_POST[Day] ;    $Month =$_POST[Month] ; $Year =$_POST[Year]     ;  $Joined_Date = $Year."-".$Month."-".$Day ;
    			$Country =htmlentities(mysql_real_escape_string($_POST[Country]));				
    			
    			$query ="insert into export_letter (Name,Address,Joined_Date,Country ) values('$Name','$Address' ,'$Joined_Date','$Country' )";
    			mysql_query($query) or die(mysql_error());	
    			$msg ="You have created new person";	
    }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <form name="form1" method="post" action="">
      <table width="643" height="55" border="0" align="center" cellpadding="0" cellspacing="3" bordercolor="#A8A8A8" class="stylewhite">
        <tr>
          <td width="97"> Full Name </td>
          <td width="167">
            <input name="Name" type="text" id="Name"></td>
          <td width="108">Address</td>
          <td width="207"><input  name="Address" type="text" id="Address"></td>
          <td width="46">&nbsp;</td>
        </tr>
        <tr>
          <td>Joined Date</td>
          <td>
    	  
              <select name="Day" id="Day">
                <?php  
    		for($i=1 ;$i<32 ;$i++)
    		{
    		
    	  
    		 echo "<option >".$i."</option>" ;  
    	
             }  
    		   ?>
              </select>
              <select name="Month" id="select2">
                <?php  
    		for($i=1 ;$i<13 ;$i++)
    		
    	 
    	 {
    		 echo "<option >".$i."</option>" ;  
    	 
             }  
    		   ?>
              </select>
              <select name="Year" id="select3">
                <?php 
    	 for($i=2010 ;$i<2021 ;$i++)
    		{
    		
    		 echo "<option >".$i."</option>" ;  
    	 
             }  
    		   ?>
                
                    
                    
                    
            
            
    	 ?>
            </select></td>
          <td>Country</td>
          <td><select name="Country" id="Country">
              <option>Djibouti</option>
              <option>USA</option>
              <option>Canada</option>
              <option>South Africa</option>
              <option>Somali</option>
              <option>China</option>
              <option>Japan</option>
              <option>Other</option>
          </select></td>
          <td>&nbsp;</td>
        </tr>
      </table>
      <table width="491" border="0" align="center" class="MsgStyle">
        <tr>
          <td width="101" height="34">&nbsp;</td>
          <td width="84">&nbsp;</td>
          <td width="127"><input name="ADD" type="submit" class="formbutton" id="Submit" value="ADD"></td>
          <td width="161"><input name="Change" type="submit" class="formbutton" id="Submit2" value="Change"></td>
        </tr>
      </table>
      <p>&nbsp;</p>
    </form>
    </body>
    </html>
    
    
    Code (markup):
    and here is the getSession function which is in the page session.php

    
      // log out if no session
    function getSession($session){
    session_start();
    session_regenerate_id(true);
    		if ((!isset($session)) || (empty($session)) ) {
    		header("Location: ../Tools/Sign_out.php");
    		exit();		
    		}
      
    }
    
    PHP:
    I accept any other correction if exist !!
     
    mahdi_fci3, Aug 30, 2010 IP
  2. mahdi_fci3

    mahdi_fci3 Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    waaaaaaaaaaaw.
    I added the header of my page to following code then the error goes away is it right ??
    
    ini_set('session.cache_limiter', 'private');
    
    PHP:
    I think the error was from session
     
    mahdi_fci3, Aug 30, 2010 IP