Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Posts
    702
    Thanks
    0
    Thanked 0 Times in 0 Posts

    file_get_contents--->email comes have html code in it and NOT graphic/text...?

    http://www.louravilla.com/pch/apply_aff.php
    I try the file_get_contents('email-manual.php'); to above webpage but email comes have html code in it and NOT graphic/text...? The message comes is the same as confirm page and about 95% same as html form see below:
    I also include email received , well ?

    <?php

    /* recipients */
    $email = $_POST['email'];
    $to = "a080725@cytanet.com.cy";
    if ($email != '') { $to .= ','.$email; }

    $subject = "Affiliate Sign-Up Request - PafosCarHire.com"; // new form field

    $first = $_POST['first'];
    $last = $_POST['last'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $fax = $_POST['fax'];
    $company = $_POST['company'];
    $biz = $_POST['biz'];
    $title = $_POST['title'];
    $country = $_POST['country'];
    $url = $_POST['url'];
    $type = $_POST['type'];
    $visitors = $_POST['visitors'];
    $notes = $_POST['notes'];

    $message = file_get_contents('apply_aff_email.php');

    $headers = "From:a080725@cytanet.com.cy";
    $headers .= "\nBcc: $email";
    $headers .= "\nReply-To:a080725@cytanet.com.cy";

    $sentOk = mail($to,$subject,$message,$headers);
    echo "sentOk=" . $sentOk;


    include_once ("apply_aff_email.php");

    ?>

    email---to a080725@cytanet.com.cy
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>New Affiliate Sign Up</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head>

    <body>
    <p> <!-- #BeginLibraryItem "/Library/top.lbi" -->
    <div align="center"><b><font size="4"><b><font face="Arial" color="#0000ff"><a name="TOP"></a></font></b></font><font face="Arial" color="#0000FF" size="2"><a href="index.php" style="text-decoration: none">Home</a>&nbsp; -&nbsp; <a href="about_us.php" style="text-decoration: none">About
    Us</a>&nbsp; -&nbsp; <a href="fleet.php" style="text-decoration: none">Our
    Fleet</a>&nbsp; -&nbsp; <a href="rates.php" style="text-decoration: none">Rates</a>&nbsp; -&nbsp; <a href="terms.php" style="text-decoration: none">Terms</a>&nbsp; -&nbsp; <a href="reservations.php" style="text-decoration: none"> Reservations</a>&nbsp; -&nbsp; <a href="contact_us.php" style="text-decoration: none">Contact
    Us</a></font></b></div>
    <!-- #EndLibraryItem -->
    </p>
    <p>&nbsp; </p>
    <table width="550" height="509" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td height="154" colspan="2" valign="top" class="text1"><p align="center"><img src="http://www.louravilla.com/pch/images/affiliate.gif" width="337" height="48"></p>
    <p>To join the program please complete the form below and one of <br>
    our webmasters will be in contact with you shortly. <br>
    <br>
    * = Required fields <?= $first ?> <br>
    </p></td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td valign="top" class="text1"><div align="center">First Name* : </div></td>
    <td width="50%" valign="top">
    <p>
    <input name="first" type="text" id="first" value="<?= $first ?> " size="40" maxlength="100"> </p></td>
    </tr>
    <tr>
    <td class="text1" valign="top"><div align="center">Last Name* : </div></td>
    <td valign="top"><input name="last" type="text" id="last" value="<?php echo "$last" ?>" size="40" maxlength="100"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td valign="top" class="text1"><div align="center">Email* : </div></td>
    <td valign="top"> <input name="email" type="text" id="email" value="<?php echo $email ?> " size="40" maxlength="100"></td>
    </tr>
    <tr>
    <td class="text1" valign="top" width="50%"><div align="center">Phone* : </div></td>
    <td valign="top">
    <input name="phone" type="text" id="phone" value="<?php echo "$phone" ?>" size="40" maxlength="40"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td valign="top" class="text1"><div align="center">Fax: </div></td>
    <td valign="top"><input name="fax" type="text" id="fax" value="<?= $fax ?> " size="40" maxlength="40"></td>
    </tr>
    <tr>
    <td class="text1" valign="top"><div align="center">Company (firm) name* : </div></td>
    <td valign="top">
    <input name="company" type="text" id="company" value="<?= $company ?> " size="40" maxlength="100"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td valign="top" class="text1"><div align="center">Company main business*
    : </div></td>
    <td valign="top">
    <input name="biz" type="text" id="biz" value="<?= $biz ?> " size="40" maxlength="100"></td>
    </tr>
    <tr>
    <td class="text1" valign="top"><div align="center">Position/Title (within
    company)* : </div></td>
    <td valign="top">
    <input name="title" type="text" id="title" value="<?= $title ?> " size="40" maxlength="100"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td valign="top" class="text1"><div align="center">Country, State* : </div></td>
    <td valign="top">
    <input name="country" type="text" id="country" value="<?= $country ?> " size="40" maxlength="100"></td>
    </tr>
    <tr>
    <td class="text1" valign="top"><div align="center">Website URL* : </div></td>
    <td valign="top">
    <input name="url" type="text" id="url" value="<?= $url ?> " size="40" maxlength="100"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td valign="top" class="text1"><div align="center">Type of Website* : </div></td>
    <td valign="top">
    <input name="type" type="text" id="type" value="<?= $type ?> " size="40" maxlength="100"></td>
    </tr>
    <tr>
    <td class="text1" valign="top"><div align="center">Unique visitors per month*
    : </div></td>
    <td valign="top">
    <input name="visitors" type="text" id="visitors" value="<?= $visitors ?> " size="40" maxlength="40"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td height="89" valign="top" class="text1"><div align="center">Notes: </div></td>
    <td valign="top"><label>
    <textarea name="notes" cols="36" rows="5" id="notes"><?= $notes ?>
    </textarea>
    </label></td>
    </tr>
    <tr>
    <td valign="top"></td>
    <td valign="top" align="right"></td>
    </tr>
    </table>
    <p>&nbsp;</p>
    <!-- #BeginLibraryItem "/Library/bottom.lbi" -->
    <style type="text/css">
    <!--
    .style1 {
    font-family: Arial, Helvetica, sans-serif;
    font-weight: bold;
    }
    -->
    </style>
    <p align="center" style="margin-top: 0; margin-bottom: 0"><b><font face="Arial" color="#0000FF" size="2"><a href="index.php" style="text-decoration: none">Home</a>&nbsp; -&nbsp; <a href="about_us.php" style="text-decoration: none">About
    Us</a>&nbsp; -&nbsp; <a href="fleet.php" style="text-decoration: none">Our
    Fleet</a>&nbsp; -&nbsp; <a href="rates.php" style="text-decoration: none">Rates</a>&nbsp; -&nbsp; <a href="terms.php" style="text-decoration: none">Terms</a>&nbsp; -&nbsp; <a href="reservations.php" style="text-decoration: none"> Reservations</a>&nbsp; -&nbsp; <a href="contact_us.php" style="text-decoration: none">Contact Us</a></font></b></p> <p align="center" style="margin-top: 0; margin-bottom: 0"><font face="Arial" size="2">Copyright<b> </b>&copy; 200<span lang="en-gb">7</span>&nbsp; </font> <span class="style1"><font size="2">Pafos
    Car Hire</font> </span><font face="Arial" size="2"> @ POLIS&nbsp;&nbsp;&nbsp;All
    rights reserved</font></p>
    <!-- #EndLibraryItem --><p>&nbsp; </p>
    </body>
    </html>

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    No content type is specified, so it is sending as text/plain by default.

    And if you're just getting the contents of the file, the code will not be parsed... it will be sent and viewed just the same as it looks when you have the file opened locally in a text-editor.

    To parse the file and get the desired output, change this:
    PHP Code:
    $message file_get_contents('apply_aff_email.php'); 
    ...to this:
    PHP Code:
    ob_start();
    include(
    'apply_aff_email.php');
    $message ob_get_clean(); 
    And add this to $headers to make it an HTML email:
    PHP Code:
    $headers .= "\nContent-Type: text/html; charset=UTF-8";
    $headers .= "\nMIME-Version: 1.0"
    You also have some repetitive code, such as:
    PHP Code:
    $email $_POST['email']; 
    And be sure to sanitize the user-submitted information, such as checking if the email is properly formatted. Your code is open to header injection.
    Last edited by kbluhm; 06-06-2007 at 10:12 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •