PHP to PDF probems

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
php-forum Fan User
php-forum Fan User
Posts: 974
Joined: Mon Oct 01, 2012 12:32 pm

Fri Apr 12, 2013 11:44 am

It looks like your calls to $dompdf -> load_html() are overwriting the same value. The easy solution is to concatenate your fields first. I'd say just at the beginning do:

Code: Select all

if($_POST &&!empty($_POST['content1'])) {
    $content = '';
    foreach ($_POST as $key => $value) {
        if ($key == 'name') {
            $name = $value;
        } else {
            $content .= $value;
    $img = "<img src=\"head.PNG\"/>";

    include_once('dompdf/' );

    $dompdf = new DOMPDF();
        if (isset($error)) {
            echo $error;
        <form method="post" action="index1.php">
            <img src="head.PNG" name="img" width="200px" align="left">
            <p>Name<textarea name="name"></textarea></p>
            <p>Temporalis<textarea name="content1"></textarea></p>
            <p>Orbicularis occuli<textarea name="content2"></textarea></p>
            <p>Sternoclediomastoid<textarea name="content3"></textarea></p>
            <p>Orbicularis oris<textarea name="content4"></textarea></p>
            <p>Massefer<textarea name="content5"></textarea></p>
            <p>Platysma<textarea name="content6"></textarea></p>
            <input type="submit" name="submit" id="submit"/>


***edit*** minor change to code

php-forum Super User
php-forum Super User
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Sun Apr 14, 2013 7:37 pm

Did you try $dompdf->load_html($name.$img.$content); ?

Post Reply