Ok so what I though should be pretty easy has got me going crazy. I cannot figure out a conditional statement to get this to work the way I need it to.

This is my first page index.html which is a form and will post to the next page below

<div id="Includes_area">
<input type="text" id="Includes_1" name="Includes_1" />
<input type="text" id="Includes_1" name="Includes_2" />
<input type="text" id="Includes_1" name="Includes_3" />
<input type="text" id="Includes_1" name="Includes_4" />
<input type="text" id="Includes_1" name="Includes_5" />

This is the page being posted to, created.php. All I am trying to do is have the created.php only show the fields that have had entry, and if none have had entry to not show any part of the Divs or anything.

    <li> <?php echo("$Includes_1")?></li>
    <li> <?php echo("$Includes_2")?></li>
    <li> <?php echo("$Includes_3")?></li>
    <li> <?php echo("$Includes_4")?></li>
    <li> <?php echo("$Includes_5")?></li>

I would appreciate any help on this, thank you !

You need to use the $_POST array.

$Includes_1 = isset($_POST['Includes_1']) ? $_POST['Includes_1'] : '';
$Includes_2 = isset($_POST['Includes_2']) ? $_POST['Includes_2'] : '';
$Includes_3 = isset($_POST['Includes_3']) ? $_POST['Includes_3'] : '';
$Includes_4 = isset($_POST['Includes_4']) ? $_POST['Includes_4'] : '';
$Includes_5 = isset($_POST['Includes_5']) ? $_POST['Includes_5'] : '';

$NoValues = empty($Includes_1) and empty($Includes_2) and empty($Includes_3) and empty($Includes_4) and empty($Includes_5);

if (! $NoValues) // at least one has a value
  echo '<div><h3>Includes</h3></div><div><ul>';

  if (!empty($Includes_1))
    echo "<li>$Includes_1</li>";

  if (!empty($Includes_2))
    echo "<li>$Includes_2</li>";

  if (!empty($Includes_3))
    echo "<li>$Includes_3</li>";

  if (!empty($Includes_4))
    echo "<li>$Includes_4</li>";

  if (!empty($Includes_5))
    echo "<li>$Includes_5</li>";

  echo '</ul></div>';
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.