I am using php to get textarea value using post method but getting a weird result with that let me show you my code
Always (always, always, I'm not kidding) use htmlspecialchars()
:
echo htmlspecialchars($_POST['contact_list']);
Try this:
<?php /* the php */ ?>
<?php
if ($_POST['submit']) {
// must work
echo $_POST['contact_list'];
};
?>
<?php /* and the html */ ?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>teszt</title>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<textarea id="contact_list" name="contact_list"></textarea>
<input type="submit" name="submit" value="Send" id="submit"/>
</form>
</body>
</html>
Make sure your escaping the HTML characters
E.g.
// Always check an input variable is set before you use it
if (isset($_POST['contact_list'])) {
// Escape any html characters
echo htmlentities($_POST['contact_list']);
}
This would occur because of the angle brackets and the browser thinking they are tags.
See: http://php.net/manual/en/function.htmlentities.php
//My Form
<form id="someform">
<div class="input-group">
<textarea placeholder="Post your Comment Here ..." name="post" class="form-control custom-control" rows="3" style="resize:none"></textarea>
<span class="input-group-addon">
<button type="submit" name="post_comment" class="btn btn-primary">
Post
</button>
</span>
</div>
</form>
//your text area get value to URL
<?php
if(isset($_POST['post_comment']))
{
echo htmlspecialchars($_POST['post']);
}
?>
//print the value using get
echo $_GET['post'];
//url must be like this
http://localhost/blog/home.php?post=asdasdsad&post_comment=
//post value has asdasdsad so it will print to your page
Remove some of your textarea class like
<textarea name="Address" rows="3" class="input-text full-width" placeholder="Your Address" ></textarea>
To
<textarea name="Address" rows="3" class="full-width" placeholder="Your Address" ></textarea>
It's dependent on your template (Purchased Template).
The developer has included some JavaScript to get the value from correct object on UI,
but class like input-text
just finds only $('input[type=text]')
, that's why.
it is very simply. Just write your php value code between textarea tag.
<textarea id="contact_list"> <?php echo isset($_POST['contact_list']) ? $_POST['contact_list'] : '' ; ?> </textarea>