-2

I am trying to post text throught textarea, but I have a problem, my prob is that textarea is inside popup and when I submit form get empty string, thus I can't to insert only textarea value, with other inputs that are outside popup doesn't have problem.

HTML:

<form action="index.php" method="post">
<!-- here are some input texts -->
<input type="text">.........

<!-- but here is a button, when click it show this popup which is written below -->
<input type="button" onclick="showPopup()">

<!-- popup -->
<div id="overlay"></div>
<div id="popup">
<textarea name="txt"></textarea> 
<input id="hidepopup" onclick="hidePopup()" type="button" value="Hide popup">
</div>

<input type="submit" name="submit" value="Submit Form">
</form>

PHP:

if(isset($_POST["submit"])
{
    $textarea = $_POST["txt"];
    $query = "INSERT INTO table ";
    $query .= "(text, other inputss....) VALUES("'$textarea', other inputs...")";
    $result = mysql_query($con, $query);
    if($result) {
       echo $textarea; // here I get empty string :(
    }

}
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Gex Nuka
  • 1
  • 6

1 Answers1

0

You don't have an input with name "submit", so

if(isset($_POST["submit"]) { ... }

You never go in this condition.

This should work:

<input type="submit" name="submit" value="Submit Form">

or

<input type="hidden" name="submit" value="1"> //this goes somewhere in the form
mariobgr
  • 2,143
  • 2
  • 16
  • 31
  • i have an input with name "submit", but here I quickly made ​​an example how it looks approximately and forgot to write the name of the input. – Gex Nuka Sep 16 '14 at 14:08
  • Well, then, I can suggest adding a hidden input IN the form, then use jquery to fill the value of this input whenever someone changes the contents of the textarea... and please, sanitize before inserting into db... – mariobgr Sep 16 '14 at 14:13