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...

 

Link to comment
Share on other sites

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;
} 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.