简体   繁体   中英

Displaying texts and html using php

I have this code below that is working perfectly. It sends the data to the DB and at the same time it sends an email with the data, but I could not figure out how to make the image as an attachment. There is an image on the database which they have uploaded.

$query = "INSERT INTO postoffers(postedby,reqName,reqEmail,reqHotel,reqOutlet,reqCnum,reqPostType,reqPostHead,reqPostDet,offerStarts,offerEnds,file,type,size) VALUES('$cuser','$rname','$remail','$rhotel','$routlet','$rcnum','$rposttype','$rposthead','$rpostdet','$rbdate','$redate','$file','$file_type','$file_size')";

        $res = mysql_query($query);

        if ($res) {
            $errTyp = "success";
            $errMSG = "Successfully Posted!";

            $to = $remail;
            $subject = "Your Post Offer";   
            $message = "Hello <strong>" . $cuser . "</strong>,";
            $message .= "<table width='600' border='0' cellspacing='10' cellpadding='0'>
                         <tbody>
                         <tr>
                            <td>This is a confirmation that you have posted a new offer for The Concierge App. Please kindly see the details below.</td>
                         </tr>
                         <tr><td>
                         <table width='600' border='1' cellspacing='0' cellpadding='10' bordercolorlight='#B4B1B1'>
                         <tbody>
                            <tr>
                                <td width='166'><strong>Requester Name :</strong></td>
                                <td width='374'>" . $rname . "</td>
                            </tr>
                            <tr>
                                <td width='166'><strong>Email :</strong></td>
                                <td width='374'>" . $remail . "</td>
                            </tr>
                                <td width='166'><strong>Hotel :</strong></td>
                                <td width='374'>" . $rhotel . "</td>
                            <tr>
                                <td width='166'><strong>Outlet Name/Spa Name :</strong></td>
                                <td width='374'>" . $routlet . "</td>
                            </tr>
                            <tr>
                                <td width='166'><strong>Contact Number :</strong></td>
                                <td width='374'>" . $rcnum . "</td>
                            </tr>
                            <tr>
                                <td width='166'><strong>Post Type :</strong></td>
                                <td width='374'>" . $rposttype . "</td>
                            </tr>
                            <tr>
                                <td width='166'><strong>Post Headline :</strong></td>
                                <td width='374'>" . $rposthead . "</td>
                            </tr>
                            <tr>
                                <td width='166'><strong>Post Details :</strong></td>
                                <td width='374'>" . $rpostdet . "</td>
                            </tr>
                            <tr>
                                <td width='166'><strong>Post Begin Date :</strong></td>
                                <td width='374'>" . $rbdate . "</td>
                            </tr>
                            <tr>
                                <td width='166'><strong>Post End Date :</strong></td>
                                <td width='374'>" . $redate . "</td>
                            </tr>
                            <tr>
                                <td width='166'><strong>Display Image :</strong></td>
                                <td width='374'>" . $file . "</td>
                            </tr>
                         </tbody>
                         </table>
                         </td></tr>
                         </tbody>
                         </table>";

            $headers = 'From: AFPWebSpecialist@gmail.com' . "\r\n" .
            $headers = "MIME-Version: 1.0" . "\r\n" .
            $headers = "Content-type:text/html;charset=iso-8859-1" . "\r\n" .
                        'Reply-To: afpwebspecialist@gmail.com' . "\r\n" .
                       'X-Mailer: PHP/' . phpversion();

            mail($to, $subject, $message, $headers);

worst part of it this

<tr>
    <td width='166'><strong>Display Image :</strong></td>
    <td width='374'>" . $file . "</td>
</tr>

Piece of code displays the file name of the image.

You should use the proper tag to display an image. Your code should look like this:

<td><img src='$file'></td>

The $file should contain the URL of your image

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM