I'm trying to pass a hidden value into my php mail script - the img1 isn't displaying - in the e-mail it's coming across with just and not the img1 value

The html form is here:

<form name="customemail" action="mail.php" onsubmit="return SubMail_Validator(this)" method="POST">
                 <input type="text" name="from" size="25"><br>
             <input type="hidden" name="imageTwo" id="imageTwo" value="<?php echo $_REQUEST['show_image']; ?>"/>

             <input type="hidden" name="imageOne" id="imageOne"/>

             <input type="image" src="../images/buy_green.jpg" border="0"><p>

The mail script is here:

$to ="";
$from = $_POST['from']; 
$msg = $_POST['msg'];
$img1 = $_POST['imageOne'];
$img2 = $_POST['imageTwo'];
//Image in e-mail
$sillimg = '<a href=""><img src="'.$img1.'" class=imageOne imageOrig></a>';
$mailimg = '<a href=""><img src="'.$img2.'"></a>';
//Mail Body - Position, background, font color, font size...
$body ='
body, P.msoNormal, LI.msoNormal
background-position: top;
background-color: #336699;
margin-left:  10em;
margin-top: 1em;
font-family: "verdana";
font-size:   10pt;
font-weight:bold ;
color:    "000000";

.container {
    position: relative;

.imageOrig {
    position: absolute;

.image {
    position: absolute;

.imageOne {
    z-index: 0;

.imageTwo {
    z-index: 1;  
  filter: alpha(opacity=50);
  opacity: 0.5;
//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 .= 'To: System Admin <>' . "\r\n";
$bodys .= "<div class='container'>";
$bodys .= "<table border='0'>";
$bodys .= "<tr>";
$bodys .= "<td valign='top' align='top'>";
#$bodys .= "<img name='hidimgSrcOrig' id='hidimgSrcOrig' class='imageOne imageOrig'>";
$bodys .= "$sillimg";
$bodys .= "$mailimg"; 
$bodys .= "<br/>";
$bodys .= "</td>";
$bodys .= "</tr>";
$bodys .= "</table>";
$bodys .= "</div>";
$bodys .= "A custom image has just been uploaded<br><br>";
$bodys .= "$from";
$bodys .= "<br>";
#$bodys .= "$mailimg";
$subject .="Custom Image";
$body .= $bodys . "</body></html>";
mail($to, $subject, $body, $headers);

Recommended Answers

All 3 Replies

Using a tool like firebug, developer tools, or element inspector (depending on what browser you are using) you should be able to view the source live and ensure that the value is indeed getting set inside your imgTwo field. Also - what does the subMailValidator look like? Perhaps there is a leading "/" inside the path being passed. Just a few things to check out quick. The code looks like it should work just fine.

Ok that's a good idea - the subMailValidator looks like this:

<script language="JavaScript">
function SubMail_Validator(customemail)
var imgSrcOrig = myImg.toString();

    if (customemail.from.value == "")
        alert("Please enter a value for the E-mail field.");
    return (false);

    if (customemail.from.value.indexOf('@',0 ) == -1) 
        alert("Invalid E-mail Address"); 


  return (true);


So I got all this working! What I had to do was add just one line to the code found in the mail php script:

<script type="text/javascript" src="nextPrevious.js"></script>

Once I did that - everything worked!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.