Recently I am developing a rich text editor. Considering that textarea can only input text, I use the contenteditable="true" attribute of p to implement rich text, which can insert pictures, videos, etc.
But here comes the problem, on the form page:
<form action="test.php" method="post">
<p contenteditable="true" name="zhengwen"></p>
<input type="submit">
</form>
In this way, the content in p cannot be submitted to the test.php page at all, and echo $_POST[zhengwen]; is not output.
I suspect it was not submitted at all.
Does anyone know how to solve it? Looking for simple codes for form submission page and receiving page! ! !
It is indeed not submitted because the submit button in the form only submits the form elements. And
<p contenteditable="true">
is not a form element.If you want to submit the information of
<p contenteditable="true">
, you need to construct thePOST
request yourself. I will use jQuery as an example:Of course, there are many ways to write jQuery's POST submission, such as
$.ajax()
, etc.When receiving on the PHP side, just read
$_POST
as usual.