Jump to content

How to prevent that certain info shows up on the 'result' page?


lookielookies

Recommended Posts

Hi

 

I find it hard to explain what my question is, so I'll be using an example below.

 

This is a simple form code:

 

<form id="form1" name="form1" method="post" action="result.php">
My name is<br />
  <label>
  <input type="text" name="textfield" />
  </label>
<p>Site:</p>
  <label>
  <input type="text" name="textfield2" />
  </label>
<p>Extra info:</p>
  <label>
  <textarea name="textarea"></textarea>
  </label>
<p></p>
  <label>
  <input type="submit" name="Submit" value="Submit" />
  </label>
</form>

 

 

 

This is 'result.php':

 

<p>Hi<em> <?PHP echo $_POST["textfield"];?> 
</em></p>
<p>You've registered <em> <?PHP echo $_POST["textfield2"];?>  </em>as your site.</p>
<p>This is your extra info: <em>  <?PHP echo $_POST["textarea"];?> </em></p>
<p>  </p>

 

 

If the 'Extra Info' form field is left blank, can I prevent that part from showing up on the 'result.php' page?

 

 

Greetz!

Mieke

Yeah.. do this

 

<?php
if ($_POST['textfield2'] != "") $siteline = "<p>You've registered <em> $_POST["textfield2"] </em>as your site.</p>"; // if it's not empty, then set as var

echo "
  <p>Hi<em>{$_POST["textfield"]}</em></p>
  $siteline
  <p>This is your extra info: <em>{$_POST["textarea"]}</em></p>
  <p> </p>
";
?>

beaten to it  :P, anyways will post

 

put a if statement in your result.php page

 

 

<p>Hi<em> <?php echo $_POST["textfield"];?> 
</em></p>
<p>You've registered <em> <?php echo $_POST["textfield2"];?>  </em>as your site.</p>
<?php if (isset($_POST['textarea'])) {?>
<p>This is your extra info: <em>  <?php echo $_POST["textarea"];?> </em></p>
<?php } ?>
<p>  </p>

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.