NYCPHP Meetup

NYPHP.org

[nycphp-talk] Passing info entered into HTML FORMS into SESSIONvariables.

PaulCheung paulcheung at tiscali.co.uk
Wed Nov 28 16:58:30 EST 2007


I am have a real problem with HTML FORMS and I cannot see where I am going 
wrong. I make a MySQL call and bring back the required data and populate a 
HTML page (all working OK) At the bottom of the page I open an HTML FORM the 
idea being the user may enter what they want and when they hit "SUBMIT" the 
info is POSTED to an UPDATE_DB subroutine. The HTML FORMS just does not work 
and I cannot see why not.

<?PHP session_start(); ob_start(); $access = $_SESSION['access']; PHP?>
<HTML>
<?PHP include("count.js"); ?>
</SCRIPT>

HTML & PHP CODING
HTML & PHP CODING
HTML & PHP CODING
HTML & PHP CODING

EVERYTHING WORKING AS EXPECTED AND REQUIRED UPTO THIS POINT
At this point I want the users to enter data and click "SUBMIT" which all 
happens as expected. AT this point here is the FORMS coding

<FORM ACTION="tp_update_tr.php" ID="primary" METHOD="post">
<TABLE BOARDER="0">
 <TBODY>     <TR bgcolor="#cccccc">
          <TD width="180">DESCRIPTION</TD>
          <TD width="50"> </TD>
          <TD width="740"><CENTER>MAXIMUM FIELD LENGTHS 
APPLY</CENTER></TD></TR>
      <TR><TD>ACTUAL OUTPUT:</TD>
          <TD><INPUT disabled="count" name="actualdata_ct" size="2" 
value="128"></TD>
          <TD><TEXTAREA name="actualdata" cols="106" 
rows="2"></TEXTAREA></TD></TR>
      <TR><TD>ACTUAL RESULT:</TD>
          <TD><INPUT disabled="count" name="actualresult_ct" size="2" 
value="255"></TD>
          <TD><TEXTAREA name="actualresult" cols="106" 
rows="3"></TEXTAREA></TD></TR>
      <TR><TD>TEST NOTE :</TD>
          <TD><INPUT disabled="count" name="testnote_ct" size="2" 
value="255"></TD>
          <TD><TEXTAREA name="testnote" cols="106" 
rows="3"></TEXTAREA></TD></TR>
         </TBODY>
</TABLE>
<?PHP
        echo("<tr><td align='right' colspan=2>$prv");
 if ($cps == $nr0)
 { echo "  |  <font color='CCCCCC'> Next - 135</font>"; }
 else
 { if ($nr0 > 1)
  { echo("  |  <a href='help_tp_update.php?cps=$cps&lps=$lps'><BUTTON>Next 
138</BUTTON></a>"); }
 }
       echo(" - <B>(Record $x of $y)</B>");
        $_SESSION['testno'] = $h;
        $actualdata         = $_POST['actualdata'];
        $actualresult       = $_POST['actualresult'];
        $testnote           = $_POST['testnote'];
        $_SESSION['actualdata']   = $actualdata;
        $_SESSION['actualresult'] = $actualresult;
        $_SESSION['testnote']     = $testnote;
        if ($v != null)
        { echo("<BR><B>PREVIOUS TESTNOTE: </B>" . $v . "<BR>");}
?>
</TABLE>
<TABLE BOARDER="0">
 <TBODY>     <TR><TD width="180"> </TD>
          <TD width="50" > </TD>
          <TD width="760"> </TD></TR>
                    <TR><TD><a href="tp_mainmenu.php" 
 ><BUTTON>EXIT</BUTTON></a>
                        <a href="#" onclick="window.print()"><?PHP echo(' | 
'); PHP?><BUTTON>Print</BUTTON></a></TD>
                        <TD><input value="UPDATE - 163" 
type="submit"></TD></TR>
         </TBODY>

</BODY>
</TABLE>
</FORM>
</HTML>

----- Original Message ----- 
From: "Michael Southwell" <michael.southwell at nyphp.com>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Sunday, November 18, 2007 9:02 PM
Subject: Re: [nycphp-talk] Passing info entered into HTML FORMS into 
SESSIONvariables.


> PaulCheung wrote:
>>        $t = $row['data']; $u = $row['result']; $v = $row['note'];
>
> How are you populating the $row array?  I would have expected this to be:
>     $t = $_POST['data'];
> Doing it this way you should have no problem. And by the way, you don't 
> need the $t etc variables unless you are using them elsewhere. That would 
> make it this:
>     $_SESSION['data'] = $_POST['data'];
>
> -- 
> =================
> Michael Southwell
> Vice President, Education
> NYPHP TRAINING:  http://nyphp.com/Training/Indepth
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php 




More information about the talk mailing list