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 = '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>';

?>

Link to comment
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.