I'm able to pass the data ok, but the form fields First and Last are blank in php5. In IE there are not clues the data is being passed. But, in Firefox when either form field is double clicked, a pull down menu appears and one of the menu items has the passed data - other menu items are passed values from prior tests. I can provide the entire form, but I think these are the critical lines. Attached are the form images, one in php4, the other in php5.

<?php
session_start();
$SESSION['sessFirst'];
$
SESSION['sessLast'];

$sessFirst = $POST['First'];
$sessLast = $
POST['Last'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
..................

<form action=".......................... >
..................
<p>
<input name="First" id="First" type="text" class="req" size="20" tabindex="1" value="<?php echo $sessFirst; ?>"/> <span class="style12"> &nbsp;&nbsp;Last&nbsp;&nbsp; </span>
<input name="Last" id="Last" type="text" class="req" size="20" tabindex="2" value="<?php echo $sessLast; ?>" />
</p>
....................
<body>
</body>
</html>

    What are these lines supposed to do:

    $_SESSION['sessFirst'];
    $_SESSION['sessLast'];

    ? Also, as it is, your script stores nothing in the session.

      bradgrafelman;10878026 wrote:

      What are these lines supposed to do:

      $_SESSION['sessFirst'];
      $_SESSION['sessLast'];

      ? Also, as it is, your script stores nothing in the session.

      The last 2 lines in the script stores the data into the session. I'm not sure what the 1st 2 lines do - I copied this from somewhere. Originally, they were in session register statements which are now obsolete. I imagine the script can be shortened with $SESSION['sessFirst'] = $POST['First'];

      <?php
      session_start();
      $SESSION['sessFirst'];
      $
      SESSION['sessLast'];

      $sessFirst = $POST['First'];
      $sessLast = $
      POST['Last'];
      ?>

        Since the <FORM> tag wasn't complete, I can't really tell you if there was a problem in the way that you're sending the data. But I modified the code slightly (Removed the session variables), and completed it the way that I assume that you are doing it, and it works for me, here's what the code that I tested:

        <?php
        
        $sessFirst = (isset($_POST['First']) ? $_POST['First'] : "");
        $sessLast = (isset($_POST['Last']) ? $_POST['Last'] : "");
        ?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>Untitled Document</title>
        </head>
        
        <form action="#" method="post">
        <p>
        <span class="style12"> &nbsp;&nbsp;First&nbsp;&nbsp; </span>
        <input name="First" id="First" type="text" class="req" size="20" tabindex="1" value="<?php echo $sessFirst; ?>"/> 
        <span class="style12"> &nbsp;&nbsp;Last&nbsp;&nbsp; </span>
        <input name="Last" id="Last" type="text" class="req" size="20" tabindex="2" value="<?php echo $sessLast; ?>" />
        </p>
        <input type="submit" />
        </form>
        <body>
        </body>
        </html>

        Hope that helps!

          woodeye;10878129 wrote:

          Since the <FORM> tag wasn't complete, I can't really tell you if there was a problem in the way that you're sending the data. But I modified the code slightly (Removed the session variables), and completed it the way that I assume that you are doing it, and it works for me, here's what the code that I tested:

          <?php
          
          $sessFirst = (isset($_POST['First']) ? $_POST['First'] : "");
          $sessLast = (isset($_POST['Last']) ? $_POST['Last'] : "");
          ?>
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
          <title>Untitled Document</title>
          </head>
          
          <form action="#" method="post">
          <p>
          <span class="style12"> &nbsp;&nbsp;First&nbsp;&nbsp; </span>
          <input name="First" id="First" type="text" class="req" size="20" tabindex="1" value="<?php echo $sessFirst; ?>"/> 
          <span class="style12"> &nbsp;&nbsp;Last&nbsp;&nbsp; </span>
          <input name="Last" id="Last" type="text" class="req" size="20" tabindex="2" value="<?php echo $sessLast; ?>" />
          </p>
          <input type="submit" />
          </form>
          <body>
          </body>
          </html>

          Hope that helps!

          Great start - with or without the PHPs in the square brackets it works correctly in Firefox. It still doesn't work in IE. If the PHPs in the square brackets are included, the IE produces thes error messages:

          Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/r/i/c/richardnday/html/Q_FORM small.php:1) in /home/content/r/i/c/richardnday/html/Q_FORM small.php on line 2
          
          Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/r/i/c/richardnday/html/Q_FORM small.php:1) in /home/content/r/i/c/richardnday/html/Q_FORM small.php on line 2

            Don't use the php in the brackets. That should only be used in the forum. I think something else in your code is causing your problems. Is the code too long to post all? If so, post as much as possible.

            I just checked this in IE, and it works fine.

            
            <?php
            
            $sessFirst = (isset($_POST['First']) ? $_POST['First'] : "");
            $sessLast = (isset($_POST['Last']) ? $_POST['Last'] : "");
            ?>
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
            <title>Untitled Document</title>
            </head>
            
            <form action="#" method="post">
            <p>
            <span class="style12"> &nbsp;&nbsp;First&nbsp;&nbsp; </span>
            <input name="First" id="First" type="text" class="req" size="20" tabindex="1" value="<?php echo $sessFirst; ?>"/> 
            <span class="style12"> &nbsp;&nbsp;Last&nbsp;&nbsp; </span>
            <input name="Last" id="Last" type="text" class="req" size="20" tabindex="2" value="<?php echo $sessLast; ?>" />
            </p>
            <input type="submit" />
            </form>
            
            <?php
            	echo "First: ".(!empty($sessFirst) ? $sessFirst : "Not Set")."<br>";
            	echo "Last: ".(!empty($sessLast) ? $sessLast : "Not Set");
            ?>
            <body>
            </body>
            </html>
            

            Don't include the [ php ] tags.

              I removed the php in [] - must have killed something vital {that should have encouraged me to rename files before changing them.} current status - this runs in php4, both IE & FFox and now neither in php5. Says fields not set.

              <?php
              session_start();
              $sessFirst = (isset($_POST['First']) ? $_POST['First'] : "");
              $sessLast = (isset($_POST['Last']) ? $_POST['Last'] : ""); 
              
              ?>
              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
              <html xmlns="http://www.w3.org/1999/xhtml"><head>
              	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
              	<style type=  ..................................................................
              
              <script>
              
              .......................................................
              <script>
              <!--
              function init()
              	{
              		prepareForm();
              	}
              
              function MM_findObj(n, d) { //v4.01
                var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
              	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
                if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
                for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
                if(!x && d.getElementById) x=d.getElementById(n); return x;
              }
              
              
              .....................................................
              
              <body onload="prepareForm()">
              <table border="2" cellpadding="8">
              
                <tr>
              	<td valign="top" bgcolor="#670065"><p>&nbsp;</p>        </td>
              <td width="620" valign="top" bgcolor="#670065" class="rainbackgr">
              
              <form action="http://RichHealthPlans.com/webber.php" method="get" enctype="multipart/form-data" name="quote_form" id="quote_form" onSubmit="MM_validateForm('First','','R','Last','','R','address1','','R'...................................);return document.MM_returnValue"  >
                <table border="8" cellpadding="1" id="Form0">
                  <tr >
                    <td width="80" height="26"><p class="style10">Applicant</p></td>
                    <td width="515" colspan="4" valign="middle" bgcolor="#FFFF99"><div align="center" class="style33"><em>Required fields have this background </em></div></td>
                  </tr>
                  <tr>
                    <td><div align="right" class="style12">
                        <p>First </p>
                    </div></td>
                    <td colspan="4"><div align="left" class="style12">
                        <p>
                          <input name="First" id="First" type="text" class="req"  size="20" tabindex="1" value="<?php echo $sessFirst; ?>"/>
                          &nbsp;&nbsp;Last&nbsp;&nbsp;
                          <input name="Last" id="Last" type="text" class="req" size="20" tabindex="2"  value="<?php echo $sessLast; ?>" />
                        </p>
                    </div></td>
                  </tr>
              
              
                </table>
              </form></td>
              <?php
                  echo "First: ".(!empty($sessFirst) ? $sessFirst : "Not Set")."<br>";
                  echo "Last: ".(!empty($sessLast) ? $sessLast : "Not Set");
              ?> 
              	  </tr>
              	</table>
              	  <table><tbody id="waitingRoom" style="display: none"></tbody></table>
              	  <<!--WEBSITECEO:BEGIN:{764EEF2E-BC11-45CF-8627-300CE1BA2219}-->
              
              </body>
              </html>
              

                The first problem that I see is that you're using the "GET" method in your form declaration, but the $POST function when capturing the variables. I would change the method in your form declaration to "POST". You could change your PHP to do a $REQUEST or $_GET, but I always prefer to send data via POST whenever possible, and I don't see why this wouldn't be possible here.

                The next issue is the action, is this page calling itself? Or where are these variables being set? Do you need to have session variables? This script as is, doesn't set any session variables.

                Sorry to hear that you overwrote your files. Its always a good idea to save previous versions of all your code, you never know when you may want to go back to something. I usually put a revision number on the old code like "script_r01.php". It helps me keep track of things.

                  woodeye;10878255 wrote:

                  The first problem that I see is that you're using the "GET" method in your form declaration, but the $POST function when capturing the variables. I would change the method in your form declaration to "POST". You could change your PHP to do a $REQUEST or $_GET, but I always prefer to send data via POST whenever possible, and I don't see why this wouldn't be possible here.

                  The next issue is the action, is this page calling itself? Or where are these variables being set? Do you need to have session variables? This script as is, doesn't set any session variables.

                  Sorry to hear that you overwrote your files. Its always a good idea to save previous versions of all your code, you never know when you may want to go back to something. I usually put a revision number on the old code like "script_r01.php". It helps me keep track of things.

                  1) recall, the problem is why are the form fields First & Last - lines 2 & 3 set these session variables [as a result of your fix]
                  2) in php4 I was unable to do a double post [form pages 1&2 after the index.html page - I've shown you form page 1] ; the get method resolved this. maybe the multiple post will work better with php5 . I'll try it again after the blank fields problem is resolved.
                  3) the session variables are needed to initialize the fields First & Last.

                  I appreciate the time you are spending trying to help.

                    The reason I'm trying to understand the need for the session variables is that maybe the lines that initialize the variables should be something like this:

                    $sessFirst = (isset($_SESSION['First']) ? $_SESSION['First'] : "");
                    $sessLast = (isset($_SESSION['Last']) ? $_SESSION['Last'] : "");
                    

                    But the bigger issue that I'm not understanding is where these variables are being set. If this is Form 1, then those session variables aren't going to be set when the script is executed, so they will always be blank.

                    As a test, try replacing the initializing of the variables with this:

                    $sessFirst = (isset($_SESSION['First']) ? $_SESSION['First'] : "First Name Not Set");
                    $sessLast = (isset($_SESSION['Last']) ? $_SESSION['Last'] : "Last Name Not Set");
                    

                    If you run that, and it shows "First Name Not Set" then you know that the data isn't being passed, which means that you have to look at the form that is calling this page and figure out why the data isn't coming through.

                    EDIT:
                    If you e-mail me your files I could take a better look at it, if you want.

                      woodeye;10878271 wrote:

                      The reason I'm trying to understand the need for the session variables is that maybe the lines that initialize the variables should be something like this:

                      $sessFirst = (isset($_SESSION['First']) ? $_SESSION['First'] : "");
                      $sessLast = (isset($_SESSION['Last']) ? $_SESSION['Last'] : "");
                      

                      But the bigger issue that I'm not understanding is where these variables are being set. If this is Form 1, then those session variables aren't going to be set when the script is executed, so they will always be blank.

                      As a test, try replacing the initializing of the variables with this:

                      $sessFirst = (isset($_SESSION['First']) ? $_SESSION['First'] : "First Name Not Set");
                      $sessLast = (isset($_SESSION['Last']) ? $_SESSION['Last'] : "Last Name Not Set");
                      

                      If you run that, and it shows "First Name Not Set" then you know that the data isn't being passed, which means that you have to look at the form that is calling this page and figure out why the data isn't coming through.

                      EDIT:
                      If you e-mail me your files I could take a better look at it, if you want.

                      The process is www.xyz.com ===>>> form page1 via $post - then, after this form page1 ===>>> form page2 via get or post ; so you suggested initializing with

                      $sessFirst = (isset($_POST['First']) ? $_POST['First'] : "");
                      $sessLast = (isset($_POST['Last']) ? $_POST['Last'] : ""); 
                      

                      These session variables are used to fill the form page1 fields First & Last.

                      I can email all if you prefer.

                        jalea148 wrote:

                        These session variables are used to fill the form page1 fields First & Last.

                        But those aren't session variables; session variables come from the $_SESSION array. When is this data supposed to be taken from the form, when is it supposed to be taken from the session, and if it is supposed to be taken from the session when and how is it supposed to have got in there?

                        I can email all if you prefer.

                        This forum does provide the facility to attach files to posts.

                          jalea148;10878279 wrote:

                          The process is www.xyz.com ===>>> form page1 via $post - then, after this form page1 ===>>> form page2 via get or post ; so you suggested initializing with

                          $sessFirst = (isset($_POST['First']) ? $_POST['First'] : "");
                          $sessLast = (isset($_POST['Last']) ? $_POST['Last'] : ""); 
                          

                          These session variables are used to fill the form page1 fields First & Last.

                          I can email all if you prefer.

                          I went back to an earlier version of the full code and inserted these php lines for First & Last. Works like a charm in both IE & Firefox. Guess I must have killed some vital code when preparing a shortened version for the forum. Thank you for all you help and patience.

                            Write a Reply...