which function to use to read data from a text area?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
crazytopu
Forum Contributor
Posts: 259
Joined: Fri Nov 07, 2003 12:43 pm
Location: London, UK
Contact:

which function to use to read data from a text area?

Post by crazytopu »

this is my php file

Code: Select all

<?php
<html>
<body>
<?php

if(isset($_POST['submit'])){


$to=$_POST['to'];
$sub=$_POST['sub'];
$msg=$POST['msg'];

echo "you want to send email to : "."$to<br>";
echo "your email subject is : "."$sub<br>";
echo "your message is "."$msg";



}else{

?>




<form method="POST" action="<?php echo $PHP_SELF?>">
  
  <table border="0" width="100%">
    <tr>
      <td width="11%" align="right"><b>To</b></td>
      <td width="89%"><input type="text" name="to" size="20"></td>
    </tr>
    <tr>
      <td width="11%" align="right"><b>Subject</b></td>
      <td width="89%"><input type="text" name="sub" size="20"></td>
    </tr>
    <tr>
      <td width="11%" align="right"><b>Message</b></td>
      <td width="89%"><textarea rows="2" name="msg" cols="20"></textarea></td>
    </tr>
  </table>
  <p align="left"><input type="submit" value="Submit" name="submit"><input type="reset" value="Reset" name="reset"></p>
</form>


<?php
}
?>


</body>

</html>

?>
I am just wondering why my

Code: Select all

echo "$msg"
doesnot give any output? It is aparent that $msg contains no data. why is that ? is this becuase it is reading text from a text area and not from a text field? is there any function other than $_POST to read data from a text area?
evilMind
Forum Contributor
Posts: 145
Joined: Fri Sep 19, 2003 10:09 am
Location: Earth

Post by evilMind »

$POST['msg']; should be $_POST['msg'];

also as a shortcut you can use the "short" php tags for simply echo'ing a variable like $PHP_SELF

eg:

Code: Select all

<form action="<?=$_SERVER&#1111;'PHP_SELF']?>" method="post" enctype="multipart/form-data">
... rest of code
Post Reply