lookielookies Posted December 6, 2007 Share Posted December 6, 2007 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 Quote Link to comment Share on other sites More sharing options...
therealwesfoster Posted December 6, 2007 Share Posted December 6, 2007 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> "; ?> Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 6, 2007 Share Posted December 6, 2007 beaten to it , 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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.