PHP variable not getting passed back to Javascript

I’m trying to pass a status flag variable from a PHP function back to the calling Javascript function, to no avail. I’'m using the “echo” command, but it’s not passing it. What am I screwing up?

The Javascript function:

<script language="javascript"> function videoRequest(){ var statusflag = "null"; gscPD("SendVideoRequest", "&emailSubject=" + ("Video order") + "&custName=" + gev("tfCustName") + "&emailAddressFrom=" + gev("tfEmailAddressFrom") + "&videoID=" + gev("tfVideoID") + "&preroll=" + gev("tfPreroll") + "&postroll=" + gev("tfPostroll") + "&emailBody=" + ("NAME: ") + gev("tfCustName") + ("\n") + ("EMAIL: ") + gev("tfEmailAddressFrom") + ("\n") + ("VIDEO ID(s): ") + gev("tfVideoID") + ("\n") + ("PREROLL:") + ("\n") + gev("tfPreroll") + ("\n") + ("POSTROLL:") + ("\n") + gev("tfPostroll")); statusflag = "<?php echo $phpstatusflag;?>"; if (statusflag == "submitted") { window.location = "http://www.myurl.com/testit.shtml" } else if (statusflag == "error") { window.alert("All fields must contain valid data.") } else { window.alert("Form submission error.") }; }// end videoRequest </script>

The PHP function:

[php]<?php
$phpstatusflag = “null”;
$toName = ‘’;
$subject = $_REQUEST[‘emailSubject’];
$fromName = $_REQUEST[‘custName’];
$fromAddress = $_REQUEST[‘emailAddressFrom’];
$videoID = $_REQUEST[‘videoID’];
$preroll = $_REQUEST[‘preroll’];
$postroll = $_REQUEST[‘postroll’];
$toAddress = ‘[email protected]’;
$bodyText = stripslashes($_REQUEST[‘emailBody’]);
$bodyTextHTML = $bodyText;
$bodyHTML;
$linkTargets = array();
$linkTargets[] = ‘(http://www.myurl.com)’;
$linkTargets[] = ‘(http://myurl.com)’;
$linkTargets[] = ‘(www.myurl.com)’;
$linkTargets[] = ‘(myurl.com)’;
$linkPre = ’ ';
$linkPost = ‘
’;
$tLinkString = “”;
$tLinkTarget = “”;

$bodyTextHTML = ereg_replace(implode('|', $linkTargets), $linkPre . 'http://www.myurl.com' . $linkPost,     $bodyTextHTML);
$bodyTextHTML = str_replace("\n", '<br />' . "\n", $bodyTextHTML);

if (strlen($fromName) && strlen($fromAddress) && strlen($videoID) && strlen($preroll) && strlen($postroll)) {
$bodyHTML = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"><link rel="stylesheet" type="text/css" href="http://www.myurl.com/pwstylemail.css"></head><body bgcolor="#ffffff" text="#000000"><div class="emailContentDIV">' . $bodyTextHTML . '</div></body></html>';
 SendEmail($toName, $toAddress, $fromName, $fromAddress, $subject, $bodyText, $bodyHTML);
 $phpstatusflag = "submitted";
 } else {
 $phpstatusflag = "error";

}
?>[/php]

Are these two different files?

Yes, the Javascript function is inside an HTML page and the PHP function is a standalone file.

Sponsor our Newsletter | Privacy Policy | Terms of Service