I vould like to send the div content in a form. But do not works! Can you please help me to find the missing part? The information sent in the db table is missing "empty space".
HTML
<form class="myform" action="file.php" method="POST">
<div id="mydiv">
<p>Marco</p>
</div>
<input type="hidden" name="dataInput" id="myinput">
<button class="mybutton" type="submit">send</button>
</form>
JAVASCRIPT
let myForm = document.querySelector(".myform");
myForm.addEventListener("submit", function(x){
x.preventDefault();
let myInput = document.getElementById("myinput");
let myDiv = document.getElementById("mydiv");
myInput.value = myDiv.innerHTML;
myForm.submit();
});
PHP file.php
$info= $_POST['dataInput'];
$data="INSERT INTO friends (
friend) VALUES(
'$info');";
$results = mysqli_query($conn, $data);