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

Link to comment
Share on other sites

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>
";
?>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.