I want to send some values with php sessions through the current page(eg.php) to another page(a.php). But i cannot make it because some error. just like
"Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\eg.php:6) in C:\xampp\htdocs\eg.php on line 14"
How to resolve it?
My eg.php code
session_start();
define("Username",$name);
define("Password",$password);
$_SESSION['user'] = $name;
echo "<form action =\"\" method = \"post\">";
echo "<input type =\"text\" placeholder =\"Username\" name = \"user\">";
echo "<input type =\"password\" placeholder = \"password\" name = \"pass\">";
echo "<input type =\"submit\" value =\"name\" name = \"btn\">";
echo "</form>";
if(isset($_POST['user']) === true && isset($_POST['pass']) === true){
$_SESSION['user'] == Username;
session_write_close();
header("location:a.php");
}
My a.php code
echo "Welcome ".$_SESSION['user'];