Jump to content

[SOLVED] Text area qestion.


czukoman20

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/70978-solved-text-area-qestion/
Share on other sites

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.

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       [email protected]\n";

 

Thats just the main parts that u need to see. im confused as to why this isnt working.

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.

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.