1

Good evening, I have two subscription forms (mailclimp) i want to pass the email value from one php page to another. In the code below i add the
/** session_start(); **/ in comments because show me some errors.

The first page :

    <?php
    /** session_start(); **/
    ob_start();
    $_SESSION['varname'] = $var_value;
    ?>

  <input type="email" placeholder="Email Address" 
    name="varname" value="var_value" class="required email" id="mce-EMAIL">

The second page:

<?php
/** session_start(); **/
ob_start();
$var_value = $_SESSION['varname'];
?>

  <input type="email" name="varname" value="<?php echo $var_value?>" 
    class="required email" id="mce-EMAIL">

But not passed the email value from the first page to another. Also i try to add as parameter the cookies, but the problem not solved.

//One page 1
$_COOKIE['varname'] = $var_value;

//On page 2
$var_value = $_COOKIE['varname'];

Updates I add this wireframe to help the users the process that i want to fix. enter image description here

1 Answer 1

1

first.php:

<?php
session_start();
$_SESSION['wdm_email'] = '[email protected]';
?>

-

second.php:

<?php
session_start();
echo 'Hi ' . $_SESSION['wdm_email'];
?>

-

When you will run second.php(after first.php), output would be:

Hi [email protected]

-

Do not forget to start the session at the top of the pages.

For more references: How to use session?

5
  • thanks for the response. I dont want to "echo" the email field from another page to another, but i want to pass the email value. I edit my question and i include the wireframe to help the users better.
    – user24259
    Mar 9, 2016 at 11:19
  • Also i realized that if i remove my comments of session_start() then i receive some errors like : session_start(): Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\theme\wp-includes\class.wp-styles.php:127) , how can fix that?
    – user24259
    Mar 9, 2016 at 11:35
  • Please start the session at the top of the page.
    – Domain
    Mar 11, 2016 at 5:28
  • @WishmLabs, i add the _SESSION(); at the top of the page. General i don't want to pass the name but the value of the email field.
    – user24259
    Mar 12, 2016 at 6:45
  • Please session in not working in my computer. How can I fix it. But same program is working in another computer.
    – Emmanuel
    Feb 18, 2021 at 23:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.