Jump to content

PHP AJAX Conformation


cfgcjm

Recommended Posts

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 = '[email protected]';
$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>';

?>

Link to comment
https://forums.phpfreaks.com/topic/96900-php-ajax-conformation/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/96900-php-ajax-conformation/#findComment-495859
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/96900-php-ajax-conformation/#findComment-495993
Share on other sites

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="" />]]>

Link to comment
https://forums.phpfreaks.com/topic/96900-php-ajax-conformation/#findComment-496023
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.