Jump to content

$_POST['textarea'] problem


robert_gsfame

Recommended Posts

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

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.

<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';

}
}
}
?>

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.