Page 1 of 1

Transfer Values between forms

Posted: Tue Sep 13, 2005 4:00 pm
by ethoemmes
Hi

I have the following code which process's a users input from a comments form. One of the fields is a check box which asks the user if they would like to be added to the mailing list. What I would like is for the values the user has already entered in the comments form to be transferred to the mailing list form (Name, email, etc).

I have assigned all values to a session variables. How would I load these values into the mailing list form?

Code for processing comments form

Code: Select all

<?php
session_start();
header("Cache-control: private");

$Title = $_POST['Title'];
$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];
$Email = $_POST['Email'];
$Comments = $_POST['Comments'];
$AddToML = $_POST['AddToML'];

$_SESSION['Title'] = $Title;
$_SESSION['FirstName'] = $FirstName;
$_SESSION['LastName'] = $LastName;
$_SESSION['Email'] = $Email;

$strMailTo = 'Edgar@rrbltd.com';
$strSubject = 'Enquiry from Website';
$strBody = "$Comments \n
Received from \n
$Title $FirstName $LastName \n
$Email
$AddToML";

$From = "From: \"$FirstName $LastName\" <$Email>\nX-Mailer: PHP/" . phpversion();

mail ($strMailTo, $strSubject, $strBody, $From);

if (isset($_POST['AddToML'])) {
header( "Location: http://www.rrbltd.com/Development/Regis ... rm_v1a.htm" );
}
else {
header( "Location: http://www.rrbltd.com");
}

?>
Code for mailing list form

Code: Select all

<HTML>
<HEAD>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="en-us">
<TITLE>Registration Form</TITLE>
<link href="../stylesheets/styles.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY>
<table width="90%" cellspacing="0" align="center" cellpadding="0" class="body">
  <tr>
    <td width ="20%" align="left"> <img src="../banner.gif" title="Rudi Thoemmes Rare Books" /> </td>
    <td align="center" valign="middle"><span class="title">Registration Form </span></td>
  </tr>
  <tr>
    <td align="left" valign="top"><table width="100%"  border="0" cellpadding="5" cellspacing="0" class="current">
        <tr>
          <td><a href="index.html" class="links">Index</a></td>
        </tr>
        <tr>
          <td>Current Catalogue</td>
        </tr>
        <tr>
          <td>Mailing List </td>
        </tr>
        <tr>
          <td>Company Outline </td>
        </tr>
    </table></td>
    <td align="left">
    <div align="center">
      <center>
      <table width="100%"  border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
      <tr>
        <td align="center"><FORM METHOD="POST" ACTION="form.php">
        <p>Please provide the following contact information:</p>
    <TABLE width="505">
          <TR>
            <TD ALIGN="left" width="103"> <font size="2">Title</font><span lang="en-gb"><font size="2">
            *</font></span></TD>
            <TD width="252">
              <select name="Title" id="select">
                <option value="Mr" selected>Mr</option>
                <option value="Mrs">Mrs</option>
                <option value="Ms">Ms</option>
                <option value="Miss">Miss</option>
                <option value="Doctor">Doctor</option>
                <option value="Professor">Professor</option>
              </select></TD>
            <TD width="136" rowspan="14" class="boxborder">
              <p class="small" align="center"><span lang="en-gb">To be added to
              the mailing list s</span>imply fill in your details<span lang="en-gb">,
              </span>check they are correct and click Submit<span lang="en-gb">.</span></p>
              <p class="body" align="center"><span lang="en-gb">A field marked
              with an asterisks must be completed. </span></p>
              <p class="body" align="center"><span lang="en-gb">If you have any
              comments please use this link</span> </p>
              <p>&nbsp;</TD>
          </TR>
          <TR>
            <TD ALIGN="left" width="103"> <font size="2">First Name</font><span lang="en-gb"><font size="2">
            * </font></span></TD>
            <TD width="252">
              <INPUT TYPE=TEXT NAME="FirstName" SIZE=21>
            </TD>
          </TR>
          <tr>
            <TD ALIGN="left" width="103"> <font size="2">Middle Name</font><span lang="en-gb"><font size="2">
            *</font></span></TD>
            <TD width="252">
              <INPUT TYPE=TEXT NAME="MiddleName" SIZE=21>
            </TD>
          </tr>
          <TR>
            <TD ALIGN="left" width="103"> <font size="2">Last Name</font><span lang="en-gb"><font size="2">
            *</font></span></TD>
            <TD width="252">
              <INPUT TYPE=TEXT NAME="LastName" SIZE=21>
            </TD>
          </TR>
          <TR>
            <TD ALIGN="left" width="103"> <font size="2">E-mail</font><span lang="en-gb"><font size="2">
            *</font></span></TD>
            <TD width="252">
              <INPUT TYPE=TEXT NAME="Email" SIZE=25>
            </TD>
          </TR>
          <TR>
            <TD ALIGN="left" width="103"> &nbsp;</TD>
            <TD width="252">
              &nbsp;</TD>
          </TR>
          <TR>
            <TD ALIGN="left" width="103"> <font size="2">Organization</font></TD>
            <TD width="252">
              <INPUT TYPE=TEXT NAME="Organization" SIZE=25></TD>
          </TR>
          <TR>
            <TD ALIGN="left" width="103"> <font size="2">Address</font></TD>
            <TD width="252">
              <INPUT TYPE=TEXT NAME="Address1" SIZE=25></TD>
          </TR>
          <TR>
            <TD ALIGN="left" width="103"> <font size="2">Address</font></TD>
            <TD width="252">
              <INPUT TYPE=TEXT NAME="Address2" SIZE=25></TD>
          </TR>
          <tr>
            <TD ALIGN="left" width="103"> <font size="2">City</font></TD>
            <TD width="252">
              <INPUT TYPE=TEXT NAME="City" SIZE=23></TD>
          </tr>
          <tr>
            <TD ALIGN="left" width="103"> <font size="2">State/County</font></TD>
            <TD width="252">
              <INPUT TYPE=TEXT NAME="State" SIZE=23></TD>
          </tr>
          <TR>
            <TD ALIGN="left" width="103"> <span lang="en-gb"><font size="2">Zip</font></span><font size="2"> Code</font></TD>
            <TD width="252">
              <INPUT TYPE=TEXT NAME="PostCode" SIZE=12></TD>
          </TR>
          <TR>
            <TD ALIGN="left" width="103"> <font size="2">Country</font></TD>
            <TD width="252">
              <INPUT TYPE=TEXT NAME="Country" SIZE=25></TD>
          </TR>
          <TR>
            <TD ALIGN="left" width="103"> <font size="2">Telephone</font></TD>
            <TD width="252">
              <INPUT TYPE=TEXT NAME="Phone" SIZE=25 MAXLENGTH=25>
&nbsp; </TD>
          </TR>

          </TABLE>
      </BLOCKQUOTE>
      <p>
        <INPUT name="SUBMIT" TYPE=SUBMIT VALUE="Submit Form">
        <INPUT name="RESET" TYPE=RESET VALUE="Reset Form">
        </p>
        </FORM></td>
      </tr>
    </table></center>
    </div>
    </td>
  </tr>
</table>
</BODY>
</HTML>
TIA

Posted: Tue Sep 13, 2005 8:45 pm
by josh
if you have the values already in the session

Code: Select all

<input name="email" value="<?=$_SESSION['email']?>" />