Solved

bug in PHP code

Posted on 2009-07-04
4
308 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

0
Comment
Question by:ironpen45
  • 2
4 Comments
 
LVL 4

Expert Comment

by:martinewski
ID: 24777283
It would be interesting if you posted what's going wrong, what are the error codes you are getting also.
0
 

Author Comment

by:ironpen45
ID: 24777306
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

0
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 500 total points
ID: 24777324
There is an error in line 34 in the original snippet. It is missing a . (dot) at the end, after date(DATE_RFC822). This is correct:

                $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) . "'";
0
 

Author Closing Comment

by:ironpen45
ID: 31599785
going blind. tyvvm!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question