Results 1 to 3 of 3

Thread: Mailing html with php

  1. #1
    Join Date
    Aug 2009
    Location
    Florida
    Posts
    23
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default Mailing html with php

    I created a page to for ordering supplies and everything seems displays properly when you hit send button the mail is sent just fine, But it doesn't display the php for some reason..... Where I'm trying to echo the quantity in the email it just shows the php code. I don't expect anyone to fix the whole page but, if anyone could get me started in the right direction it would be a huge help.....

    Thanks in advance

    Code:
    <? include("accesscontrol.php");
    
    
    $pday = date('d', mktime(0,0,0,0, date(d)));
    
    $pmonth = date('m', mktime(0,0,0, date(m), date(d)));
    
    $pyear = date('Y', mktime(0,0,0,date(m) ,date(d) , date(Y)));
    
    
    if(isset($s1))
    
    {
    
    $odoban = $_POST['odoban'];
    
    mail('myemail@gmail.com', 'Supply Requisition',   
       
     '<html><body><p><b><i><table align="center" border="0" cellspacing="0" cellpadding="0"><tr><td><table style="table-layout:fixed;border:2px outset #000099" width=535 height=550 border=2 cellspacing=4 cellpadding=0><col width="167"><col width="167"><col width="167"><tr>
    <td style="border:1px inset #CCCCCC" width="165" height="21" align="left" valign="top" bgcolor="#CCCCCC"><span class="text"><b><span style="font-size:12px;line-height:19px;">
    
    ////////////////I think this is where I'm messing up?//////////////////////////
    
        
             <input name="odoban" value="<?php echo $odoban;?>" type="text" id="odoban" size="1">&nbsp;Odoban Disinfectant</b></a></span></td>
    <td style="border:1px inset #CCCCCC" width="165" height="21" align="left" valign="top" bgcolor="#CCCCCC"><span class="text"> <b><span style="font-size:12px;line-height:19px;"><input name="nav_lt" value="$nav_lt" type="text" id="odoban" size="1">&nbsp;Navigation Light Bulbs<br soft></span></u></b></a></span></td>
    <td style="border:1px inset #CCCCCC" width="165" height="21" align="left" valign="top" bgcolor="#CCCCCC"><span class="text"> <b><span style="font-size:12px;line-height:19px;"><input name="brake" value="$brake" type="text" id="brake" size="1">&nbsp;Brake-Kleen Parts Cleaner<br soft></span></u></b></a></span></td>
    
    
    
    </table>
    
    </form>
    Last edited by Snookerman; 01-14-2010 at 10:09 AM.

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    You have to set the header to accept the html and you cant have variables in single quotes if you want them to display that actual value.

    For a more detailed example

    PHP Code:
    <?php
    // multiple recipients
    $to  'aidan@example.com' ', '// note the comma
    $to .= 'wez@example.com';

    // subject
    $subject 'Birthday Reminders for August';

    // message
    $message '
    <html>
    <head>
      <title>Birthday Reminders for August</title>
    </head>
    <body>
      <p>Here are the birthdays upcoming in August!</p>
      <table>
        <tr>
          <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
        </tr>
        <tr>
          <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
        </tr>
        <tr>
          <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
        </tr>
      </table>
    </body>
    </html>
    '
    ;

    // To send HTML mail, the Content-type header must be set
    $headers  'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";

    // Additional headers
    $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' "\r\n";
    $headers .= 'From: Birthday Reminder <birthday@example.com>' "\r\n";
    $headers .= 'Cc: birthdayarchive@example.com' "\r\n";
    $headers .= 'Bcc: birthdaycheck@example.com' "\r\n";

    // Mail it
    mail($to$subject$message$headers);
    ?>
    For more info http://php.net/manual/en/function.mail.php
    Corrections to my coding/thoughts welcome.

  3. #3
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    To be more specific

    PHP Code:
    <? include("accesscontrol.php");

    $pday date('d'mktime(0,0,0,0date(d)));

    $pmonth date('m'mktime(0,0,0date(m), date(d)));

    $pyear date('Y'mktime(0,0,0,date(m) ,date(d) , date(Y)));

    if(isset(
    $s1)){

    $odoban $_POST['odoban'];
    $to  'myemail@gmail.com'
    // subject
    $subject 'Supply Requisition';

    // message
    $message '<html><body><p><b><i><table align="center" border="0" cellspacing="0" cellpadding="0"><tr><td><table style="table-layout:fixed;border:2px outset #000099" width=535 height=550 border=2 cellspacing=4 cellpadding=0><col width="167"><col width="167"><col width="167"><tr><td style="border:1px inset #CCCCCC" width="165" height="21" align="left" valign="top" bgcolor="#CCCCCC"><span class="text"><b><span style="font-size:12px;line-height:19px;"><input name="odoban" value="'$odoban .'" type="text" id="odoban" size="1">&nbsp;Odoban Disinfectant</b></a></span></td><td style="border:1px inset #CCCCCC" width="165" height="21" align="left" valign="top" bgcolor="#CCCCCC"><span class="text"> <b><span style="font-size:12px;line-height:19px;"><input name="nav_lt" value="'$nav_lt '" type="text" id="odoban" size="1">&nbsp;Navigation Light Bulbs<br soft></span></u></b></a></span></td><td style="border:1px inset #CCCCCC" width="165" height="21" align="left" valign="top" bgcolor="#CCCCCC"><span class="text"> <b><span style="font-size:12px;line-height:19px;"><input name="brake" value="'$brake '" type="text" id="brake" size="1">&nbsp;Brake-Kleen Parts Cleaner<br soft></span></u></b></a></span></td></table></form></body></html>';

    // To send HTML mail, the Content-type header must be set
    $headers  'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
    $headers .= 'From: Me <me@mydomain.com>' "\r\n";

    // Mail it
    mail($to$subject$message$headers);
    }
    ?>
    You dont need the <?php because that's going to be parsed before it's sent. You also needed to close the body and html which i added in and close the if isset which i did not sure if this was a snippet or your whole code.
    Corrections to my coding/thoughts welcome.

Bookmarks

Posting Permissions

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