I am very new to PHP programming. I'm not even sure if I'm going about this the right way. I am going to post 3 test scripts hoping that someone can tell me where I have gone wrong.
This form should take the info to test2.php and my test is to keep the variables available across multiple scripts.
File: Test1.php
<?php
//starting session
session_start ();
//setting global variables
global $name, $login, $sessiondata;
//register session varaiables
session_register("name");
session_register("login");
session_register("sessiondata");
?>
<form action="test2.php" method="post">
Username: <input type="text" name="name"><br>
Login: <input type="text" name="login"><br>
Sessiondata: <input type="text" name="sessiondata"><br>
<input type="submit" value="Submit">
</form>
This is the script that is called by the form. It should just print the data the user submitted but nothing is happening. everything is blank.
File: Test2.php
<?php
//starting session
session_start ();
//setting global variables
global $name, $login, $sessiondata;
//register session varaiables
session_register("name");
session_register("login");
session_register("sessiondata");
print (" Welcome $name <br> ");
print (" Your login is: $login <br> ");
print (" Current data entered is: $sessiondata <br> ");
print (" <a href=test3.php> Test transfer to next php page3 </a> ");
?>
The final script is just a duplicate of test2.php. Just trying to see if the variables are carrying over from script to script. They aren't!!
File: Test3.php
<?php
//starting session
session_start ();
//setting global variables
global $name, $login, $sessiondata;
//register session varaiables
session_register("name");
session_register("login");
session_register("sessiondata");
print (" Welcome $name <br> ");
print (" Your login is: $login <br> ");
print (" Current data entered is: $sessiondata <br> ");
print (" <a href=test2.php> Test transfer to next php page2 </a> ");
?>
I had some problems with my \tmp and my session.save directory. I have since cleared that problem and I am now seeing the session files being saved in the temp directory I have set in the php.ini file. It seems as though the scripts cannot access them to get the variables that have been set.
I hope someone can help me out here.. 😕 😕 😕