?
Solved

bug in PHP code

Posted on 2009-07-04
4
Medium Priority
?
333 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Independent Software Vendors: 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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses

762 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