I want to pass one session variable to other page. On my first page I have:
<?php
session_start();
?>
then:
<form class="form1" method="post" action="contact2.php" id="form1">
<ul>
<li>
<label for="name">*Name:</label>
<input type="text" name="name" placeholder="Black Nova"class="required" role="input" aria-required="true"/>
</li>
<li>
<input id="submit" class="submit .transparentButton" value="Next" type="submit" name="submit"/>
</li>
</ul>
<br/>
</form>
<?php
$_SESSION['name'] = $_POST['name'];
echo $_SESSION['name'];
?>
In my contact.php I have session start, but I cannot get sesssion variable.
If, in my first page, I dont give any action, I get the right value in $_SESSION['name'] but if I give an action, the session variable wont change. Why?
echo $_SESSION['name']produce before you set it to$_POST['name']?session_start()on the contact page before any output to the browser? Show us where it is called.contact.phpandcontact2.phpfiles are and contain.