perezf Posted August 10, 2006 Share Posted August 10, 2006 how do i get the following php code to work only when form is submittedboth php and html on same page[code]<form name="form1" method="post" action=""> <p align="center"> <input type="submit" name="Submit" value="Preview"> <br> <textarea name="practice" cols="100" rows="20"></textarea> </p></form><?php$practice = $_POST['practice'];if ($practice == NULL) {echo 'empty';}else {echo $practice;}?>[/code] Quote Link to comment Share on other sites More sharing options...
Madatan Posted August 10, 2006 Share Posted August 10, 2006 [code]<form name="form1" method="post" action=""><input type="hidden" name="gorgeusgeorge" value="1"> <p align="center"> <input type="submit" name="Submit" value="Preview"> <br> <textarea name="practice" cols="100" rows="20"></textarea> </p></form><?php$practice = $_POST['practice'];if ($practice == NULL) {echo 'empty';}elseif($gorgeusgeorge == '1') {echo $practice;}?>[/code]You could also uset isset but there are issues in IE with that. Quote Link to comment Share on other sites More sharing options...
perezf Posted August 10, 2006 Author Share Posted August 10, 2006 how would i use issetfor future reference Quote Link to comment Share on other sites More sharing options...
Madatan Posted August 10, 2006 Share Posted August 10, 2006 [code]<form name="form1" method="post" action=""> <p align="center"> <input type="submit" name="Submit" value="Preview"> <br> <textarea name="practice" cols="100" rows="20"></textarea> </p></form><?php$practice = $_POST['practice'];if ($practice == NULL) {echo 'empty';}elseif(isset($_POST['Submit'])) {echo $practice;}?>[/code] Quote Link to comment Share on other sites More sharing options...
perezf Posted August 10, 2006 Author Share Posted August 10, 2006 now how could i get the following to open a new window showing the text from the textarea box[code]<form name="form1" method="post" action=""> <p align="center"> <input type="submit" name="Submit" value="Preview"> <br> <textarea name="practice" cols="100" rows="20"></textarea> </p></form><?phpif(isset($_POST['Submit'])){$practice = $_POST['practice'];if ($practice == NULL) {echo 'empty';}else {echo $practice;}}else {}?>[/code] Quote Link to comment Share on other sites More sharing options...
perezf Posted August 10, 2006 Author Share Posted August 10, 2006 does anyone know how i can get this accomplished Quote Link to comment Share on other sites More sharing options...
Silverado_NL Posted August 10, 2006 Share Posted August 10, 2006 shouldnt the action value should be filled in and not empty like you have it there!i think it should contain the filename that your sending the POST data to!whether the practice variable contains something or not it is always send when you press submit.so checking it with isset doesnt work i think.if you dont want the form to show if you already send it, you should put it in a conditional statement.if (empty($_POST['submit'])){echo 'form and stuff';}else{echo 'show results!!!!';} 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.