czukoman20 Posted September 28, 2007 Share Posted September 28, 2007 I have a textarea that the user can put a paragraph of information in it. I am wondering. with my submit button. if there is a way to make the information of that textarea = to a variable. so then it can be used as text. <textarea name="comments" cols="40" rows="5" value=value=" <? ?>"</textarea></td><td></td></tr> <tr><td colspan="2" align="right"> That is what i have for the text area. Help is greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/70978-solved-text-area-qestion/ Share on other sites More sharing options...
marcus Posted September 28, 2007 Share Posted September 28, 2007 $comments = $_POST['comments']; echo nl2br($comments); Quote Link to comment https://forums.phpfreaks.com/topic/70978-solved-text-area-qestion/#findComment-356889 Share on other sites More sharing options...
MadTechie Posted September 28, 2007 Share Posted September 28, 2007 like this <?php $data = "TEST"; ?> <textarea name="comments" cols="40" rows="5"> <?php echo $data; ?> </textarea> Note value is for textbox not textarea Quote Link to comment https://forums.phpfreaks.com/topic/70978-solved-text-area-qestion/#findComment-356891 Share on other sites More sharing options...
czukoman20 Posted September 28, 2007 Author Share Posted September 28, 2007 Well that works for only one thing, a predefined set of wording. What i want to be able to do is make ht euser able to change that $data with that textbox. then when they hit submit button. the action e-mails this $data variable to a person. I got the e-mail form right. but i just want to make that textarea able to be edited then turned into a variable. Quote Link to comment https://forums.phpfreaks.com/topic/70978-solved-text-area-qestion/#findComment-356897 Share on other sites More sharing options...
MadTechie Posted September 28, 2007 Share Posted September 28, 2007 thats where mgallforever code comes in <textarea name="comments" cols="40" rows="5"> <?php echo nl2br($_POST['comments']); ?> </textarea> Quote Link to comment https://forums.phpfreaks.com/topic/70978-solved-text-area-qestion/#findComment-356901 Share on other sites More sharing options...
czukoman20 Posted September 28, 2007 Author Share Posted September 28, 2007 Im a bit confused as to how this works. I will show u exactly what i have. $Ecomments = nl2br($_POST['comments']); ?> <textarea name="comments" cols="40" rows="5"> <?php echo nl2br($_POST['comments']); ?> </textarea> <form action="<?php $message2 = $username4."has submitted a form of information to you $user1.,\n\n" ."This users information is as follows\n" ."----------------------------\n" ."Realname: $realname\n " ."Company: $compname\n " ."CompanyWeb: $compweb\n " ."E-mail: $email2\n " ."Address: $address\n " ."Phone: $phone\n " ."Comments: $comments\n " [b] ."Extra Comments: $Ecomments\n"[/b] ."----------------------------\n" ."If this information is suspicious. please report the user to Service@adworld-online.com\n"; Thats just the main parts that u need to see. im confused as to why this isnt working. Quote Link to comment https://forums.phpfreaks.com/topic/70978-solved-text-area-qestion/#findComment-356910 Share on other sites More sharing options...
chronister Posted September 28, 2007 Share Posted September 28, 2007 what the heck is this piece??? <form action="<?php $message2 = $username4."has submitted a form of information to you $user1.,\n\n" ."This users information is as follows\n" ."----------------------------\n" Your action cannot contain the body of the email. the action has to be a particular page. Either $_SERVER['PHP_SELF']; or an external page. Or it can be an email address.... but that is not very good to use as it will open the guests email program. Here is a simple form with a text area with a default value... copy & paste and run it. It will print the textarea value above the form. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php if(isset($_POST['button'])) { $textarea=$_POST['textarea']; echo $textarea; } ?> <form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF'] ?>"> <p> <textarea name="textarea" id="textarea" cols="45" rows="5">This is the default text..... change it and hit submit</textarea> </p> <p> <input type="submit" name="button" id="button" value="Submit" /> </p> </form> </body> </html> You gotta have a basic understanding of how an HTML form works first. Getting a value from Form Elements is pretty well the exact same. $fieldname=$_POST['fieldname']; or if method="get", then $fieldname=$_GET['fieldname']; This pretty much holds true irregardless of the type of field it is. Quote Link to comment https://forums.phpfreaks.com/topic/70978-solved-text-area-qestion/#findComment-357006 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.