0

I know people have asked questions like this that are very similar. And i have looked and looked into it but nothing seems to help me out. I'm trying to get the sessions to pass a variable (i am using xampp) but every time i get this error Undefined variable: _session in C:\xampp1\htdocs\myfiles\test2.php on line 10. Here is the code

session_start();
$_session["username"]= "Curtis";
echo ($_session["username"]);
?>
<html>
<body>

<form action = "test2.php" >

<input type = "submit" name = "submit"/>

</form>
</body>
</html>

here is the other file that the button takes you to

<?php
session_start();
?>

<!DOCTYPE html>
<html>
<body>

<?php
echo ($_session["username"]);
?>

<form action = "test3.php">
<input type = "submit"/>
</form>
</body>
</html>

so i have session_start() at the top of each page but it is still not wanting to pass the variable. Any help would be greatly appreciated

1 Answers1

-1

$_session should be $_SESSION as mentioned in the comments of your question.

Take a look at the php manual, second sentence:

Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive.

DigiLive
  • 1,093
  • 1
  • 11
  • 28