";

Echo display $ content

A short example of my problem:

$myname = "Blah Blah";

$content = "<table><tr><td>".$myname."</td></tr></table>";

<?php
echo "<table><tr><td>".$myname."</td></tr></table><form name='makepdf' action='make_pdf.php?content=$content' method='POST'><button class='cupid-green' name='submitpdf'>Prenos PDF</button></form>";
?>

I will catch $ content in make_pdf.php later ...

But the problem is that I get a double display of $ content, where the echo is presented. But if I change action = 'make_pdf.php? Content = test ', it works fine. I will also catch $ content in make_pdf.php.

I tried to do:

<input type='hidden' name='content' value='$content'>

I get similar or worse results because I will not catch $ content = $ _GET ['content']; in make_pdf.php

Any solution?

+4
source share
3 answers

in php

<?php echo "<input type='hidden' name='content' value='" . $content . "'>";

? >

in HTML

<input type="hidden" name="content" value="<?php echo htmlspecialchars($content); ?>">
0
source

Encode it using PHP htmlspecialchars :

value="<?php echo htmlspecialchars($content); ?>"
+2
source

echo -ing HTML- PHP, .

value, htmlspecialchars().

?>

<input type="hidden" name="content" value="<?= htmlspecialchars($content) ?>">

<?php
+1

Source: https://habr.com/ru/post/1531258/


All Articles