We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

bug in PHP code

ironpen45
ironpen45 asked
on
Medium Priority
453 Views
Last Modified: 2013-12-13
i'm trying to fix this PHP file. The data comes from an SWF file. Can any check my syntax? Thanks!
<?php
 
    include "config.php";
 
	$sPage		= $_REQUEST['page'];
 
	$to 		= "info@njisc.com";
	//$to 		= "melwin.mca@gmail.com";	
	$sFrom		= "info@njisc.com";
	$header 	= "From: New Jersey International Salsa Congress 2010<" . $sFrom . ">\r\n";
 
	$sIp	= $_SERVER ['REMOTE_ADDR'];
 
	if ($sPage=="1") {
 
		$sFirstName	= $_REQUEST['sFirstName'];
		$sLastName	= $_REQUEST['sLastName'];
		$sPhone		= $_REQUEST['sPhone'];
		$sEmail		= $_REQUEST['sEmail'];
		$sMessage	= $_REQUEST['sMessage'];
		//$sDateTime  = date(DATE_RFC822)
 
		$sQuery = "SELECT IDREC FROM tblContactUs ORDER BY IDREC DESC LIMIT 1";
		$rResult = mysql_query ($sQuery, $link);
	
		$row = mysql_fetch_assoc($rResult);
	
		$IDREC  = 1;
	
		if (!empty($row)) {
			$IDREC = (int)$row['IDREC'] + 1;
		}
 
		$sQuery = "INSERT INTO tblContactUs SET IDREC=" . $IDREC . ", FNAME='" . $sFirstName . "', LNAME='" . $sLastName . "', PHONE='" . $sPhone . "', EMAIL='" . $sEmail . "', COMMENTS='" . $sMessage . "', IPADDRESS='" . $sIp . "', AUTOREPLY=1, DATETIME= '" . date(DATE_RFC822) "'";
		mysql_query ($sQuery);
 
		$subject	= "Your Contact Details";
		$subject1	= "New Contact Details";		
		$body 		= "Thank you for contacting New Jersey International Salsa Congress 2010. Our staff will get to you soon.\n\n Your details are: \n\nFirst Name: " . $sFirstName . "\n\nLast Name: " . $sLastName . "\n\nPhone: " . $sPhone . "\n\nEmail Address: " . $sEmail . "\n\nMessage: " . $sMessage . "\n\n";
		$body1 		= "New contact Details: \n\nFirst Name: " . $sFirstName . "\n\nLast Name: " . $sLastName . "\n\nPhone: " . $sPhone . "\n\nEmail Address: " . $sEmail . "\n\nMessage: " . $sMessage . "\n\nIP Address: " . $sIp . "\n\nDate :" . date(DATE_RFC822);
	}
	else if ($sPage=="3") {
 
		$sFirstName	= $_REQUEST['sFirstName'];
		$sLastName	= $_REQUEST['sLastName'];
		$sPhone		= $_REQUEST['sPhone'];
		$sEmail		= $_REQUEST['sEmail'];
		$sZipCode	= $_REQUEST['sZipCode'];
		$sFlyer		= $_REQUEST['sFlyer'];
		$sComments	= $_REQUEST['sComments'];
	
		$subject	= "Your Registration Details";
		$subject1	= "New Registration Details";		
		$body 		= "Thank you for registering with New Jersey International Salsa Congress 2010. Your details are: \n\nFirst Name: " . $sFirstName . "\n\nLast Name: " . $sLastName . "\n\nPhone: " . $sPhone . "\n\nEmail Address : " . $sEmail . "\n\nZip Code : " . $sZipCode . "\n\nNumber of Flyer : " . $sFlyer . "\n\nComments : " . $sComments . "\n\n";	
		$body1 		= "New registration Details: \n\nFirst Name: " . $sFirstName . "\n\nLast Name: " . $sLastName . "\n\nPhone: " . $sPhone . "\n\nEmail Address : " . $sEmail . "\n\nZip Code : " . $sZipCode . "\n\nNumber of Flyer : " . $sFlyer . "\n\nComments : " . $sComments . "\n\nIP Address: " . $sIp . "\n\nDate :" . date(DATE_RFC822);
		
		$sQuery = "SELECT IDREC FROM tblRegister ORDER BY IDREC DESC LIMIT 1";
		$rResult = mysql_query ($sQuery, $link);
	
		$row = mysql_fetch_assoc($rResult);
	
		$IDREC  = 1;
	
		if (!empty($row)) {
			$IDREC = (int)$row['IDREC'] + 1;
		}
 
		$sQuery = "INSERT INTO tblRegister SET IDREC=" . $IDREC . ", FNAME='" . $sFirstName . "', LNAME='" . $sLastName . "', PHONE='" . $sPhone . "', EMAIL='" . $sEmail . "', ZIP='" . $sZipCode . "', FLYERNUMBER='" . $sFlyer . "', COMMENTS='" . $sComments . "', IPADDRESS='" . $sIp . "', DATETIME= date(DATE_RFC822) , AUTOREPLY=1";
		mysql_query ($sQuery);
	}
	else {
 
		$sGroupName		= $_REQUEST['sGroupName'];
		$sContactName	= $_REQUEST['sContactName'];
		$sPhone1		= $_REQUEST['sPhone1'];
		$sPhone2		= $_REQUEST['sPhone2'];
		$sEmail			= $_REQUEST['sEmail'];
		$sPerformance	= $_REQUEST['sPerformance'];
		$sDuration		= $_REQUEST['sDuration'];
		$sDancers		= $_REQUEST['sDancers'];
		$sAddress1		= $_REQUEST['sAddress1'];
		$sAddress2		= $_REQUEST['sAddress2'];
		$sCity			= $_REQUEST['sCity'];
		$sState			= $_REQUEST['sState'];
		$sComments		= $_REQUEST['sComments'];
		$sZip			= $_REQUEST['sZip'];
 
		$sQuery = "SELECT IDREC FROM tblPerformers ORDER BY IDREC DESC LIMIT 1";
		$rResult = mysql_query ($sQuery, $link);
	
		$row = mysql_fetch_assoc($rResult);
	
		$IDREC  = 1;
	
		if (!empty($row)) {
			$IDREC = (int)$row['IDREC'] + 1;
		}
 
		$sQuery = "INSERT INTO tblPerformers SET IDREC=" . $IDREC . ", GROUPNAME='" . $sGroupName . "' CONTACTNAME ='" . $sContactName . "', PHONE1='" . $sPhone1 . "', PHONE2='" . $sPhone2 . "', EMAIL='" . $sEmailAddress . "', PERFORMANCENAME='" . $sPerformance . "', DURATION='" . $sDuration . "', NDANCERS='" . $sDancers . "', ADDRESS1='" . $sAddress1 . "', ADDRESS2='" . $sAddress2 . "', CITY='" . $sCity . "', STATE='" . $sState . "', COMMENTS='" . $sComments . "', ZIP='" . $sZip . "', IPADDRESS='" . $sIp . "', AUTOREPLY=1";
		mysql_query ($sQuery);
 
		$subject	= "Your Performance Application Details";
		$subject1	= "New Performance Application Details";		
		$body 		= "Thank you for applying to be considered to perform at the New Jersey International Salsa Congress 2010. You will be contacted within 4-6 of this registration. Your details are: \n\nGroup Name: " . $sGroupName . "\n\nContact Name: " . $sContactName . "\n\nPhone Number I : " . $sPhone1 . "\n\nPhone Number II :" . $sPhone2 . "\n\nEmail Address: " . $sEmail . "\n\nPerformance: " . $sPerformance . "\n\nDuration: " . $sDuration . "\n\nDancers: " . $sDancers . "\n\nAddress Line I: " . $sAddress1 . "\n\nAddress Line II: " . $sAddress2 . "\n\nCity : " . $sCity . "\n\nState: " . $sState . "\n\nComments: " . $sComments . "\n\nZip Code: " . $sZip . "\n\n";
		$body1 		= "New performer Details: \n\nGroup Name: " . $sGroupName . "\n\nContact Name: " . $sContactName . "\n\nPhone Number I : " . $sPhone1 . "\n\nPhone Number II :" . $sPhone2 . "\n\nEmail Address: " . $sEmail . "\n\nPerformance: " . $sPerformance . "\n\nDuration: " . $sDuration . "\n\nDancers: " . $sDancers . "\n\nAddress Line I: " . $sAddress1 . "\n\nAddress Line II: " . $sAddress2 . "\n\nCity : " . $sCity . "\n\nState: " . $sState . "\n\nComments: " . $sComments . "\n\nZip Code: " . $sZip . "\n\nIP Address: " . $sIp . "\n\nDate :" . date(DATE_RFC822);
	}
 
	$to1		=  $sEmail;
 
	mail ($to1, $subject, $body, $header);
	mail ($to, $subject1, $body1, $header);
 
	echo("true");
?>

Open in new window

Comment
Watch Question

It would be interesting if you posted what's going wrong, what are the error codes you are getting also.

Author

Commented:
you're right, except when i run the process, it runs, but no email is delivered and the db on server doesn't get populated.

the process stopped after we tried to add fields to lines 34 in the INSERT section.

here's the Actionscript, that pipes in the data.

Thanks for looking.
function clearTxt() {
	tf_1.text = "First Name";
	tf_2.text = "Last Name";
	tf_3.text = "Phone";
	tf_4.text = "E-mail";
	tf_5.text = "Massage";
}
clearTxt();
bReset.onRelease = clearTxt;
tf_1.tabIndex = 0;
tf_2.tabIndex = 1;
tf_3.tabIndex = 2;
tf_4.tabIndex = 3;
tf_5.tabIndex = 4;
//tf_3.restrict = tf_2.restrict="0-9 +";
 
var result_lv:XML = new XML();
result_lv.onLoad = function(success:Boolean) {
	if (success) {
		cfMessage.text = "Your message has been sent."+"\n"+"Thank you!!";
		bSubmit2.enabled = true
 
	} else {
		cfMessage.text = "Your message not sent."+"\n"+"Please try again!";
 
	}
};
 
 
var sendMail_lv:LoadVars = new LoadVars();
 
bSubmit2.onPress = function() {
	if (tf_1.text != "" && tf_1.text != "First Name" && tf_2.text != "" && tf_2.text != "Last Name" && tf_3.text != "Phone" && tf_3.text != "" && tf_4.text != "E-mail" && tf_4.text != "" && tf_5.text != "Massage" && tf_5.text != "") {
		indexOfAt = tf_4.text.indexOf("@");
 
		lastIndexOfDot = tf_4.text.lastIndexOf(".");
 
		if (indexOfAt != -1 && lastIndexOfDot != -1) {
 
			if (lastIndexOfDot<indexOfAt) {
 
				cfMessage.text = "please verify your email.";
			} else {
 
				sendMail_lv.sFirstName = tf_1.text;
				sendMail_lv.sLastName  = tf_2.text;
				sendMail_lv.sPhone = tf_3.text;
				sendMail_lv.sEmail = tf_4.text;
				sendMail_lv.sMessage = tf_5.text;
				sendMail_lv.page = 1;
				sendMail_lv.sendAndLoad("http://newjerseyinternationalsalsacongress.com/scratch/email.php",result_lv,"POST");
				clearTxt();
				cfMessage.text = "Waiting....";
				bSubmit2.enabled = false
			}
		} else {
			cfMessage.text = "please enter correct email address";
		}
	} else {
		cfMessage.text = "Please fill all the fields.";
		if (tf_1.text == "") {
			tf_1.text = "First Name";
		}
		if (tf_2.text == "") {
			tf_2.text = "Last Name";
		}
		if (tf_3.text == "") {
			tf_3.text = "Phone";
 
		}
		if (tf_4.text == "") {
			tf_4.text = "E-mail";
 
		}
		if (tf_5.text == "") {
			tf_5.text = "Massage";
		}
 
	}
};
 
tf_1.onSetFocus = function() {
	if (tf_1.text == "First Name") {
		this.text = "";
	}
};
tf_2.onSetFocus = function() {
	if (tf_2.text == "Last Name") {
		this.text = "";
	}
};
tf_3.onSetFocus = function() {
	if (tf_3.text == "Phone") {
		this.text = "";
	}
};
tf_4.onSetFocus = function() {
	if (tf_4.text == "E-mail") {
		this.text = "";
	}
};
tf_5.onSetFocus = function() {
	if (tf_5.text == "Massage") {
		this.text = "";
	}
};
tf_1.onKillFocus = function() {
	if (this.text == "") {
		tf_1.text = "First Name";
	}
};
tf_2.onKillFocus = function() {
	if (this.text == "") {
		tf_2.text = "Last Name";
	}
};
tf_3.onKillFocus = function() {
	if (this.text == "") {
		tf_3.text = "Phone";
	}
};
tf_4.onKillFocus = function() {
	if (this.text == "") {
		tf_4.text = "E-mail";
	}
};
tf_5.onKillFocus = function() {
	if (this.text == "") {
		tf_5.text = "Massage";
	}
};

Open in new window

Top Expert 2008
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
going blind. tyvvm!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.