I have a login.html page with a form. The form takes in username and password and then calls the home.php page. The home.php
page assigns the username and password to a variable.
$username = $_POST["username"];
$password = $_POST["password"];
I also have a changepassword.html
form page which takes in oldpassword and newpassword and calls the changepassword.php page.
The changepassword.php
page assigns the old and new passwords to variables:
$oldpassword = $_POST["oldpassword"];
$newpassword = $_POST["newpassword];
On this page, I also have a link to go back to the home.php page but when I click on it, it gives me the following two error lines:
Notice: Undefined index: username in [path] on line 19
Notice: undefined index: password in [path] on line 20
I suspect that this is because changepassword.html form did not have those variables so it never got saved on $_POST
.
So when I am calling the home page from changepassword.php page (instead of the login.html
page), there is nothing to assign to those variables.
I want to get rid of those errors but dont know how. I would have thought when I logged in originally, session_start()
would have saved username and password.
I have session_start()
at the start of all files (dont know if that is correct).