I am trying to pass textbox entries to their namesake entries in another page, using sessions. In common with most other code that I write, it does not work. This code is in a separate file, landing_email.php: <?php session_start(); global $entries; if (isset ($_SESSION['entries'])) {$_SESSION['entries'] = $_SESSION['entries']+ 1; } else {$_SESSION['entries'] = 1; } $_SESSION['entries']="First Name: $firstname\nLast Name: $lastname; ?> PHP: This code is in the receiving page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php session_start( ); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <form method="post" action="https://s.p2.webhosting.yahoo.com/forms?login=my_login" name="long_form" /> <input type="text" name="firstname" value="<?php echo $_SESSION['firstname']; ?>" /> <input type="text" name="lastname" value="<?php echo $_SESSION['lastname']; ?>" /> Code (markup): This is in the first form: <form method="post" action="https://my_url.com/landing_email.php" name="life_landing" /> <input type="text" name="firstname" /> <input type="text" name="lastname" /> Code (markup): Any suggestions?
wel.. but why it must work? you set variable $_SESSION['entries'] but not set these: $_SESSION['firstname'] $_SESSION['lastname'] Code (PHP): try do smth like this (landing_email.php) ... $_SESSION['firstname']=$firstname; $_SESSION['lastname']=$lastname; $_SESSION['entries']="First Name: $firstname\nLast Name: $lastname;" Code (PHP): it must work!
Yor are correct, GuitarFix. That was a needed change. It does work. Thank you. I also needed to move: <?php session_start( ); ?> PHP: to the very top of the page with nothing whatever before it. Now it all works. Resolved!
Page1: <? session_start(); $str = 13; session_register("str") ?> Page 2: <? session_start(); echo $_SESSION['str']; ?>