Jump to content

How to avoid overwritting variable value


xox

Recommended Posts

Hello, I have a form that has a preview, before user can preview the form inputs he must login. If he is logedin, he can see preview and continue to editing form, but after user is finished with editing his values he is redirected to "preview" page for which he must be logged in. But the problem is that variables are "empty" after redirecting back to preview.

 

$_POST['email'] is received from login.php

$_SESSION['code'] is 5 digit code generated at start, it isn't important in this issue.

 

Here's the code:

 

preview.php

$id_user= 0;
$code = $_SESSION['code'];
    $email = $_POST['email'];
    $_SESSION['email_login'] = $email;

 

So now you can see that $email and $_SESSION['email_login'] are empty because when redirecting from "editing" to preview  $_POST['email'] can't be found...

 

if(isset($_POST['email']) && $_POST['email']!='')
{
    $email = $_POST['email'];
    $_SESSION['email_login'] = $email;
}
elseif (isset($_SESSION['email_login']))
{
    $email = $_SESSION['email_login'];
}
else
{
    $email = false;
} 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.