cfgcjm Posted March 19, 2008 Share Posted March 19, 2008 I have a ajax contact form that uses php and i'm trying to get it to pass an image as a conformation as opposed to text what i want if ( @$mailit ) { $posStatus = 'OK'; $posConfirmation = '<img src="/images/utility/success.gif" alt="Success!" />'; } Original (don't want) if ( @$mailit ) { $posStatus = 'OK'; $posConfirmation = 'Success!'; } It works great with just text but if i change it to the image tag it returns the text "null". Any ideas why? Full file code: <?php // change the 4 variables below $yourName = 'Chris Miller'; $yourEmail = 'chris@digiconmediagroup.com'; $yourSubject = 'News Submission'; $referringPage = 'http://stjohns.digiconmediagroup.com/news/'; // no need to change the rest unless you want to. You could add more error checking but I'm gonna do that later in the official release header('Content-Type: text/xml'); echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'; echo '<resultset>'; function cleanPosUrl ($str) { $nStr = $str; $nStr = str_replace("**am**","&",$nStr); $nStr = str_replace("**pl**","+",$nStr); $nStr = str_replace("**eq**","=",$nStr); return stripslashes($nStr); } if ( $_GET['contact'] == true && $_GET['xml'] == true && isset($_POST['posText']) ) { $to = $yourName; $subject = 'News Submission: '.cleanPosUrl($_POST['posRegard']); $message = cleanPosUrl($_POST['posText']); $headers = "From: ".cleanPosUrl($_POST['posName'])." <".cleanPosUrl($_POST['posEmail']).">\r\n"; $headers .= 'To: '.$yourName.' <'.$yourEmail.'>'."\r\n"; $mailit = mail($to,$subject,$message,$headers); if ( @$mailit ) { $posStatus = 'OK'; $posConfirmation = '<img src="/images/utility/success.gif" alt="Success!" />'; } else { $posStatus = 'NOTOK'; $posConfirmation = 'ERROR!'; } if ( $_POST['selfCC'] == 'true' ) { $ccEmail = cleanPosUrl($_POST['posEmail']); @mail($ccEmail,$subject,$message,"From: Yourself <".$ccEmail.">\r\nTo: Yourself"); } echo ' <status>'.$posStatus.'</status> <confirmation>'.$posConfirmation.'</confirmation> <regarding>'.cleanPosUrl($_POST['posRegard']).'</regarding> '; } echo' </resultset>'; ?> Quote Link to comment Share on other sites More sharing options...
Kenny Pollock Posted March 19, 2008 Share Posted March 19, 2008 It looks fine to me... but I don't know anything about XML. My guess is it's an XML problem. Try manually creating the xml file with the img code in it, see if it works. If not, refer to http://biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/200008/msg00348.html < looks like it may help Quote Link to comment Share on other sites More sharing options...
Lashiec Posted March 19, 2008 Share Posted March 19, 2008 XML uses < > as tags, so when you put... <Something>Text Here</Something> It will work, but when you try doing... <Something><img src="a.jpg" /></Something> XML sees the <img part and things it's another XML tag instead of an image tag. Or, that's what I've found. You may be able to escape the character with / or whatever XML would use to escape it and it may let you get by with <img> between two XML tags. I don't work with XML much, but I had the same problem before. I just changed it to output <Something>a.jpg</Something> Quote Link to comment Share on other sites More sharing options...
Kenny Pollock Posted March 19, 2008 Share Posted March 19, 2008 XML uses < > as tags, so when you put... <Something>Text Here</Something> It will work, but when you try doing... <Something><img src="a.jpg" /></Something> XML sees the <img part and things it's another XML tag instead of an image tag. Or, that's what I've found. You may be able to escape the character with / or whatever XML would use to escape it and it may let you get by with <img> between two XML tags. I don't work with XML much, but I had the same problem before. I just changed it to output <Something>a.jpg</Something> You have confirmed my guess. So then the solution would be to place <![CDATA[<img src="a.jpg" alt="" />]]> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.