<img> tag not transferring into $_POST varirable

the mail() function

Moderators: macek, egami, gesf

mikeglaz
New php-forum User
New php-forum User
Posts: 3
Joined: Sat Aug 27, 2011 4:46 pm

<img> tag not transferring into $_POST varirable

Postby mikeglaz » Sat Aug 27, 2011 4:52 pm

I have a page with a textarea that looks like this:
http://www.jaggednighttheatre.com/admin/newsletter.php

In my code I want the text/html contained within the textarea to be emailed to recipients. I can email text, buttons, textboxes but not the <img> tag. For some reason that doesn't go through. Anyone know why? Here's my code:

Code: Select all

<?php
session_start();   
require_once('../mysqli_connect.php');

if(isset($_POST['submitted']))
{
   $title = mysqli_real_escape_string($dbc, trim($_POST['title']));
   $date = trim($_POST['date']);
   $body = $_POST['body'];
   
   $letter = '';
   $letter = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
   $letter .= '<html xmlns="http://www.w3.org/1999/xhtml">';
   $letter .= '<body>';
   $letter .= $body;
   $letter .= '</body>';
   $letter .= '</html>';

   $to = 'mikeglaz@yahoo.com';
   $subject = 'Jagged Night Theatre';
   $headers = "From: mail@jaggednighttheatre.com\r\n";
   $headers .= 'MIME-Version: 1.0' . "\r\n";
   $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
   
   mail($to, $subject, $letter, $headers);
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Administrator Page</title>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="editNews.js"></script>
<link href="../style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
   <div id="title"><h1><img src="../JNT.jpg" /></h1>
   </div>

   <div id="container">
      <div id="buttons">
         <a href="index.php" class="button">Home</a>
         <a href="news.php" class="button">Update News</a>
         <a href="recipients.php" class="button">Recipients</a>
         <a href="newsletter.php" class="button"><span class="currentPage">Send Newsletter</span></a>
         <a href="logout.php" class="button">Logout</a>               
      </div>
   <div class="newsletter">
        <h1>Create Newsletter</h1>
        <br />
        <?php
        if(!isset($_POST['submitted']))
        {
            echo '<form action="newsletter.php" method="post" class="passwordForm">';
            echo '<table class="tableList">';
            echo '<tr>';
         echo '<td><b>Title:</b></td>';
         echo '<td><input type="text" name="title" size="40" maxlength="60" /></td>';
         echo '<tr>';
         echo '<td><b>Date:</b></td>';
         echo '<td><input type="text" name="date" size="10" maxlength="20" readonly="readonly" />';
         echo '&nbsp;<a href="" onclick="displayCalendar(8);">Select Date</a></td>';
         echo '</tr>';
         echo '</table>';

         echo '<script type="text/javascript">';
         echo 'var dateObject = new Date();';
         echo 'var month = dateObject.getMonth() + 1;';
         echo 'var dateToday = dateObject.getFullYear() + "-" + month + "-" + dateObject.getDate();';
         echo 'document.forms[0].date.value = dateToday;';
         echo '</script>';                     
         echo '</br>';

           echo '<textarea id="news" name="body" rows="20" cols="110"></textarea>';
               echo '<div class="submit">';
               echo '<input type="submit" name="submit" value="Submit" />';
               echo '&nbsp;<input type="button" value="Cancel" onclick="cancel()">';
               echo '<input type="hidden" name="submitted" value="TRUE" />';
               echo '</div>';
               echo '</form>';
         }?>
   </div>
</div>
</div>
</body>
</html>

lokanath7
New php-forum User
New php-forum User
Posts: 139
Joined: Mon Nov 15, 2010 12:11 am

Re: <img> tag not transferring into $_POST varirable

Postby lokanath7 » Mon Aug 29, 2011 6:06 am

<img> tag is not a form element. so it cant be post.

mikeglaz
New php-forum User
New php-forum User
Posts: 3
Joined: Sat Aug 27, 2011 4:46 pm

Re: <img> tag not transferring into $_POST varirable

Postby mikeglaz » Mon Aug 29, 2011 9:25 am

But <textarea> is a form element so shouldn't $_POST['body'] give me all the text entered into the textarea?

mikeglaz
New php-forum User
New php-forum User
Posts: 3
Joined: Sat Aug 27, 2011 4:46 pm

Re: <img> tag not transferring into $_POST varirable

Postby mikeglaz » Mon Aug 29, 2011 9:56 am

In other words, I want the user to be able to enter HTML markup into the text area and have the script email an HTML email including inline images.

lokanath7
New php-forum User
New php-forum User
Posts: 139
Joined: Mon Nov 15, 2010 12:11 am

Re: <img> tag not transferring into $_POST varirable

Postby lokanath7 » Mon Aug 29, 2011 11:37 pm

if u want to get the value of <img> tag in php u can do it in a diff. manner.
declare a hidden fld.
and when u submit the form in javascript between submit() [ur fnc name] u can assign the img tag value to the hidden fld and when the form submitted successfully u can find the hidden fld value in php easily.

similar condition for other elements as well....


Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 1 guest

cron