Jump to content

Results from echo not showing


tjverge

Recommended Posts

if (isset($_POST['update']))
{
$signature = $_POST['signature'];
$type = $_POST['type'];
$name = $_POST['name'];
$b=0;
While ($b < $i)
{
echo $signature[$b]."<br>";
echo $type[$b]."<br>";
echo $name[$b]."<br><br>";
$b++;
}}

 

I did echo '<pre>';

print_r($_POST);

echo '</pre>';

 

The results are

Array
(
    [sname] => 
    [notes] => 
    [signature] => Array
        (
            [0] => 1-1
            [1] => 1-2
            [2] => 1-3
        )

    [type] => Array
        (
            [0] => Test1
            [1] => Test2
            [2] => Test3
        )

    [name] => Array
        (
            [0] => Testa
            [1] => Testb
            [2] => Testc
        )

    [update] => Update
)

 

But for some reason nothing is showing up on the screen.

Link to comment
https://forums.phpfreaks.com/topic/229492-results-from-echo-not-showing/
Share on other sites

here is the whole page

 

<form action="main.php?id=todaysupdate.php" method="post">
Number of Signatures: <input name="nsigs" type="text" />
<input name="submit" type="submit" value="Enter Scan" />
</form>
<?php
if (isset($_POST['submit']))
{
echo "<form action=main.php?id=todaysupdate.php method=post>
<table border=0 cellspacing=0 cellpadding=0 width=700>
  <tr>
    <td>System Name: </td>
    <td><input name=sname type=text /></td>
    <td>Notes: </td>
    <td><input name=notes type=text /></td>
  </tr>
</table><br>

<table border=0 cellspacing=0 cellpadding=0>
  <tr>
    <td>Signature</td>
    <td>Type</td>
    <td>Name</td>
  </tr>";

$i=$_POST{'nsigs'};
$a=0;
while ($a < $i)
{
echo "<tr>
    <td><input name=signature[] type=text></td>
    <td><input name=type[] type=text></td>
    <td><input name=name[] type=text></td>
  </tr>";
$a++;
}
echo "</table>";
?>
<input name="update" type="submit" value="Update" />
</form>
<?php
}

if (isset($_POST['update']))
{
$signature = $_POST['signature'];
$type = $_POST['type'];
$name = $_POST['name'];
$b=0;
While ($b < $i)
{
echo $signature[$b]."<br>";
echo $type[$b]."<br>";
echo $name[$b]."<br><br>";
$b++;
}}
?>

You aren't passing it with the subsequent form submission, so it loses its value. Add the lines indicated by my comments in the code and try it again.

 

. . . [sNIP] . . . 
</tr>";
      $a++;
   }
   echo "<input type=\"hidden\" name=\"nsigs\" value=\"{$_POST['nsigs']}\">"; // <---- ADD THIS LINE
   echo "</table>";
?>
<input name="update" type="submit" value="Update" />
</form>
<?php
}
if (isset($_POST['update'])) {
   $i = $_POST['nsigs']; // <---- ADD THIS LINE
   $signature = $_POST['signature'];
   $type = $_POST['type'];
. . . [sNIP] . . . 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.