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

Link to comment
Share on other sites

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