I was wondering why my code, which can be trimmed down to the following structure, isn't printing what I think should be printed. Basically I have two methods and two corresponding html pages in the same php controller class. I want to retrieve the value of the POST request (html text input form) from mypage.html and print that in secondpage.html to which we are redirected when the user clicks 'submit' button after typing in their input in the text box.
Update: I just read about PHP sessions and my program does start sessions. But should I use sessions even if the user input date is saved in the database?
<? php
$var; // initializing global variable;
class MyClass {
public function mypage () {
global $var;
$var = $_POST['form_name'];
}
public function secondpage () {
global $var;
print_r($var);
}
}