robert_gsfame Posted September 7, 2009 Share Posted September 7, 2009 I need someone helps.... i have textarea, (below is the code) <form method=POST name=form action=next.php> <input type=textarea name=textarea1> <input type=submit> </form> -------- next.php -------- $textarea=$_POST['textarea1']; if(empty($textarea)){ echo "wrong";}else{ echo "true";}?> the problem is that when i left the textarea empty, it still run echo"true" command....why does this happen?? Link to comment https://forums.phpfreaks.com/topic/173378-_posttextarea-problem/ Share on other sites More sharing options...
dreamwest Posted September 7, 2009 Share Posted September 7, 2009 <?php $textarea=$_POST['textarea1']; if($textarea == ""){ echo "wrong"; }else{ echo "true"; } ?> Link to comment https://forums.phpfreaks.com/topic/173378-_posttextarea-problem/#findComment-913949 Share on other sites More sharing options...
robert_gsfame Posted September 7, 2009 Author Share Posted September 7, 2009 not working! :'( Link to comment https://forums.phpfreaks.com/topic/173378-_posttextarea-problem/#findComment-913987 Share on other sites More sharing options...
prasanthmj Posted September 7, 2009 Share Posted September 7, 2009 To create a text area, you have to use the textarea tag <textarea name='textarea1' cols='25' rows='5'></textarea> Link to comment https://forums.phpfreaks.com/topic/173378-_posttextarea-problem/#findComment-913993 Share on other sites More sharing options...
dave_sticky Posted September 7, 2009 Share Posted September 7, 2009 As prasanthmj points out, a text area has different code to what you are using. If you want a text box rather than a text area then use: <input type='text' name='textarea1' /> [EDIT] Oh, and that is XHTML Compliant not HTML Compliant. Replace " />" with ">" at the end if you are using HTML rather than XHTML. Link to comment https://forums.phpfreaks.com/topic/173378-_posttextarea-problem/#findComment-914001 Share on other sites More sharing options...
newbtophp Posted September 7, 2009 Share Posted September 7, 2009 <form method="post" action="<?php echo $PHP_SELF; ?>" /> <input type="text" name="textarea1"/></textarea> <input type="submit" name="submit" value="submit"/> </form> <?php $textarea1 = $_POST['textarea1']; $submit = $_POST['submit']; if($textarea1 == "") echo ""; else { if($submit == "submit") { //Some php here echo 'true'; } } } ?> Link to comment https://forums.phpfreaks.com/topic/173378-_posttextarea-problem/#findComment-914008 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.