I'm stuck on the The PHP Beginners Tutorial
How do I make this for post PHP 4.2
The tut shows this;
$MyTextarea = nl2br($MyTextarea);
echo($MyTextarea);
I've tried variations of this;
$MyTextarea = nl2br ($_POST['MyTextarea']);
echo $_POST['MyTextarea'];
So far I can't make it work...
Tnx.i.a.
kammy...
Using $_POST
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
To check what is in the $_POST array you can do:
at the top of the script that handles the form processing.
One thing I did notice was you have this:
and then this:
which means that you are echoing out the original variable that has not had the nl2br() function run on it. To view the text with the HTML line breaks added in you would need to do:
or if you're not going to use $MyTextarea anywhere else, why even bother making a temporary variable - just do:
Mac
Code: Select all
echo '<pre>';
print_r($_POST);
echo '</pre>';One thing I did notice was you have this:
Code: Select all
$MyTextarea = nl2br($_POST['MyTextarea']);Code: Select all
echo $_POST['MyTextarea'];Code: Select all
$MyTextarea = nl2br($_POST['MyTextarea']);
echo $MyTextarea;Code: Select all
echo nl2br($_POST['MyTextarea']);Mac
Thanks
Great explanation.
Of course both of your options work.
It's all a bit overwhelming when you've never done any coding before.
That PHP Beginners Tutorial is by far the best I've come across so far.
kammy...
Beginners Tutorial;
http://www.phpcomplete.com/tutorials.ph ... adTutorial
Read in conjunction with - Working with Form Variables in PHP 4.2+;
http://www.phpcomplete.com/tutorials.ph ... adTutorial
Of course both of your options work.
It's all a bit overwhelming when you've never done any coding before.
That PHP Beginners Tutorial is by far the best I've come across so far.
kammy...
http://www.phpcomplete.com/tutorials.ph ... adTutorial
http://www.phpcomplete.com/tutorials.ph ... adTutorial