i am trying to display variable via session to the another page to whom i send it via action in form. i am using session inside if(isset($_POST['submit'])) seems its not working. here is my form.php code
<!DOCTYPE html>
<html >
<head>
<meta content="text/html; charset=utf-8" />
<title>form</title>
</head>
<body><form action="submit.php" method="post">
<input type="text" name="username" />
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>
<?php
session_start();
if(isset($_POST['submit'])){
$username=$_POST['username'];
if(!empty($username)){
//echo $username;
$_SESSION['username']=$username;
echo 'session is set';
}
}
?>
here is my submit.php code
<?php
session_start();
//var_dump($_SESSION);
echo $_SESSION['username'];
?>
i tried all possible way, not working. i want this way for submitting. thankyou in advance.