Let's say my code looks like this:
if (isset($_POST["reset"])){
//selects email and phoneNo from database based on values entered in form
$_SESSION['email'] = $_POST['email'];
}else if (isset($_POST["submit"])) {
//line 68 -- $rePas = "UPDATE user SET 'password' = '" .password_hash($_POST['password'], PASSWORD_DEFAULT) . "' WHERE email = '$_SESSION[email]'";
}
I have session_start();
at the beginning of the page, outside any if's etc.
I enter the page to see a form that asks me to input email and phone number, then I click Reset
button, if the sql code returns something the form is changed to another form that asks me to input password. Once I do that I press Submit
button and I get $_POST['submit']
I get Notice: Undefined index: email in ... on line 68
I can't understand why the session variable is set to null after pressing submit button, is there anyway to pass a variable through two forms, if that makes sense? I have looked through stackoverflow similar question yet I couldnt find a working solution.
Looks like this piece of code and explanation is not enough therefore here is the link to full file code: https://pastebin.com/fDEBCakp