How to pass the text box data using session to the nextpage in php : I want to pass the text box data to the next page(demo2) and i need to save all the data together in my db i tried using session the value i passed is sending to the next page but i want the textbox data to be passed...

Help me out!!

Below is my code



    

**demo1.php**

<!-- begin snippet: js hide: false -->

<!-- language: lang-html -->



    **demo1.php**

    <?php
    								
    session_start();
      
     if($_POST)
     {
    		if($_POST['act'] == "add")
    	{
    		$firstname = $_POST['firstname'];
    		$lastname = $_POST['lastname'];
    		$nationality = $_POST['nationality'];	
    		
    		$conn = mysql_connect("localhost","root","");
    		$db = mysql_select_db("reg",$conn);
    						
    	}
    }

    echo "Session variables are set.";

    if(@$_GET)
    {
    	  $_SESSION["firstname"] = "$firstname";
    	  $_SESSION["lastname"] = " $lastname"; 
    	  $_SESSION["nationality"] = "$nationality"; 
    	  echo $firstname;
    	  echo $lastname;
    	  echo $nationality;
    }
     ?>
    	<!DOCTYPE html>
    <html lang="en">

    <head>

    </head>

    <body>
    	<form  method="POST">

    			<?php if(isset($_GET['id'])) { ?>
    			<input type="hidden" name="act" value="edit"/>
    			<input type="hidden" name="id" value="<?php echo $id; ?>"/>
    		
    			<?php } else{ ?>
    			<input type="hidden" name="act" value="add"/>
    			<?php } ?>
    			
    									                                            <label> FirstName</label>
                                                
    <input type="text" name="firstname" value="<?php echo @$firstname; ?>"><br>
    									
    	 <label> LastName</label>
                                                
    <input type="text" name="lastname" value="<?php echo @$lastname; ?>"><br>
    											
    <label> Nationality</label>
                                                
    <input type="text" name="nationality" value="<?php echo @$nationality; ?>"><br>

     <a href="demo2.php"> <input type="button" id="next" name="next" value="next" >

    <?PHP $_SESSION["firstname"] = "Preethi";
    														  $_SESSION["lastname"] = " Rajan"; 
    														  $_SESSION["nationality"] = "Indian"; 	?>	     
     </form>
    									
    </body>

    </html>
    	

<!-- end snippet -->




    **demo2.php**
    
    <?php
    								
    session_start();
    
     if($_POST)
    
    	{
    		if($_POST['act'] == "add")
    
    	{                                    
    		
    		$firstname= $_SESSION['firstname'];	
    		$lastname= $_SESSION['lastname'];	
    		$nationality= $_SESSION['nationality'];			
    								
    	    $mobileno = $_POST['mobileno'];
    		
    		$email = $_POST['email'];
    	
    		$commaddr = $_POST['commaddr'];
    		
    		$city = $_POST['city'];
    	
    		$pincode = $_POST['pincode'];
    		
    		$state = $_POST['state'];
    	
    		$permaddr = $_POST['permaddr'];
    
    		$conn = mysql_connect("localhost","root","");
    		$db = mysql_select_db("reg",$conn);
    
    	$sql = "INSERT INTO registration (firstname,lastname,nationality,mobileno,email,commaddr,city,pincode,state,permaddr) VALUES ('".$_SESSION["firstname"]."','".$_SESSION["lastname"]."' ,'".$_SESSION["nationality"]."', '".$mobileno."' , '".$email."' , '".$commaddr."','".$city."','".$pincode."','".$state."','".$permaddr."')";
    	
    	$rep = mysql_query($sql);
    	}
    }
    	
    	?>
    	<!DOCTYPE html>
    <html lang="en">
    
    <head>
    </head>
    	<form action="demo2.php" method="POST">
    									
    <?php if(isset($_GET['id'])) { ?>
    			<input type="hidden" name="act" value="edit"/>
    			<input type="hidden" name="id" value="<?php echo $id; ?>"/>
    		
    			<?php } else{ ?>
    			<input type="hidden" name="act" value="add"/>
    			<?php } ?>
    <label> Mobile Number</label>
                                                
    <input type="text" name="mobileno" value="<?php echo @$mobileno; ?>"><br>
    											
    <label> E Mail ID</label>
                                                
    <input type="text" name="email" value="<?php echo @$email; ?>"><br>
    
    <label> Communication Address</label>
    												 
    <input type="text" name="commaddr" value="<?php echo @$commaddr; ?>"><br>
    
    <label> City</label>
    
    <input type="text" name="city" value="<?php echo @$city; ?>"><br>
    
    <label>Pin Code</label>
    												 
    <input type="text" name="pincode" value="<?php echo @$pincode; ?>"><br>
    
    <label>State</label>
    												 
    <input type="text" name="state" value="<?php echo @$state; ?>"><br>
    
    <label> Permanent Address</label>
    												 
    <input type="text" name="permaddr" value="<?php echo @$permaddr; ?>"><br>
                                            
    <input type="submit" name="submit" value="submit"  style="height:50px; width:150px">
    
    </form>
    </body>
    
    </html>