Page 1 of 1

Newbie question

Posted: Thu Mar 31, 2011 8:53 pm
by lvninjas
Firstly, let me say I know very little about PHP coding, but can follow the basics, such as email forms.

That being said, My Email form isn't working properly... http://www.designsatwork.com/the11group/contact.php OR .html extension; I have 2 versions, both with the same conclusion. My processing (?) file, http://www.designsatwork.com/the11group/sendemail.php and the config file is in the admin folder, cryptically called config.php http://www.designsatwork.com/the11group ... config.php

All parameters look like they work, even concluding to the thanks.html page. I never receive an email, however. :banghead:

Please feel free to chide, mock or giggle, as long as you with the knowledge can help! (I know you will be good natured, and I am not a sensitive flower)
Please help... I haven't even gotten to the Captcha yet, but have my accesscode in place on the form.

Re: Newbie question

Posted: Fri Apr 01, 2011 9:55 am
by social_experiment
It would help us (and in turn you) a lot more if you can paste the code when you seek help :) When I visit your page i don't see the php code as it is already being parsed so the url didn't help at all.

Re: Newbie question

Posted: Fri Apr 01, 2011 10:29 am
by lvninjas
Touche, good point and a highlight to my newness to this.
Thanks for your patience and assistance.

Could it be that I am on an incompatible OS on the server? PHP is universal, right?


From sendemail.php

<?PHP
######################################################
# #
# Forms To Go 4.3.3 #
# http://www.bebosoft.com/ #
# #
######################################################




define('kOptional', true);
define('kMandatory', false);

define('kStringRangeFrom', 1);
define('kStringRangeTo', 2);
define('kStringRangeBetween', 3);

define('kYes', 'yes');
define('kNo', 'no');




error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set('track_errors', true);

function DoStripSlashes($fieldValue) {
// temporary fix for PHP6 compatibility - magic quotes deprecated in PHP6
if ( function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() ) {
if (is_array($fieldValue) ) {
return array_map('DoStripSlashes', $fieldValue);
} else {
return trim(stripslashes($fieldValue));
}
} else {
return $fieldValue;
}
}

function FilterCChars($theString) {
return preg_replace('/[\x00-\x1F]/', '', $theString);
}

function CheckString($value, $low, $high, $mode, $limitAlpha, $limitNumbers, $limitEmptySpaces, $limitExtraChars, $optional) {
if ($limitAlpha == kYes) {
$regExp = 'A-Za-z';
}

if ($limitNumbers == kYes) {
$regExp .= '0-9';
}

if ($limitEmptySpaces == kYes) {
$regExp .= ' ';
}

if (strlen($limitExtraChars) > 0) {

$search = array('\\', '[', ']', '-', '$', '.', '*', '(', ')', '?', '+', '^', '{', '}', '|', '/');
$replace = array('\\\\', '\[', '\]', '\-', '\$', '\.', '\*', '\(', '\)', '\?', '\+', '\^', '\{', '\}', '\|', '\/');

$regExp .= str_replace($search, $replace, $limitExtraChars);

}

if ( (strlen($regExp) > 0) && (strlen($value) > 0) ){
if (preg_match('/[^' . $regExp . ']/', $value)) {
return false;
}
}

if ( (strlen($value) == 0) && ($optional === kOptional) ) {
return true;
} elseif ( (strlen($value) >= $low) && ($mode == kStringRangeFrom) ) {
return true;
} elseif ( (strlen($value) <= $high) && ($mode == kStringRangeTo) ) {
return true;
} elseif ( (strlen($value) >= $low) && (strlen($value) <= $high) && ($mode == kStringRangeBetween) ) {
return true;
} else {
return false;
}

}


function CheckEmail($email, $optional) {
if ( (strlen($email) == 0) && ($optional === kOptional) ) {
return true;
} elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) {
return true;
} else {
return false;
}
}


function CheckValueList_accesscode($ValuesFromField, $ValidationType, $Optional) {

$ValuesListFromText[] = '4';


$SelectedValues = 0;

if ( !is_array( $ValuesFromField ) ) {
if ( strlen( $ValuesFromField) > 0 ) {
$ValuesFromField = array( $ValuesFromField );
} else {
$ValuesFromField = array();
}
}

foreach ( $ValuesFromField as $ValuesFromField_Key => $ValuesFromField_Value ) {
foreach ( $ValuesListFromText as $ValuesListFromText_Key => $ValuesListFromText_Value ) {
if ( strcasecmp( $ValuesFromField_Value, $ValuesListFromText_Value ) == 0 ) {
$SelectedValues++;
break;
}
}
reset( $ValuesListFromText );
}

if ( ( count( $ValuesFromField ) == 0 ) && ( $Optional === kOptional ) ) {
return true;
} elseif ( ( $ValidationType == 1 ) && ( $SelectedValues > 0 ) ) {
return true;
} elseif ( ( $ValidationType == 2 ) && ( $SelectedValues == count( $ValuesListFromText ) ) ) {
return true;
} elseif ( ( $ValidationType == 3 ) && ( $SelectedValues == 0 ) ) {
return true;
} else {
return false;
}

}


if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$clientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$clientIP = $_SERVER['REMOTE_ADDR'];
}

$FTGName = DoStripSlashes( $_POST['Name'] );
$FTGEmailFrom = DoStripSlashes( $_POST['EmailFrom'] );
$FTGPhone = DoStripSlashes( $_POST['Phone'] );
$FTGProductionServices = DoStripSlashes( $_POST['ProductionServices'] );
$FTGEquipRental = DoStripSlashes( $_POST['EquipRental'] );
$FTGvideography = DoStripSlashes( $_POST['videography'] );
$FTGmarketingDistribution = DoStripSlashes( $_POST['marketingDistribution'] );
$FTGPhotoServices = DoStripSlashes( $_POST['PhotoServices'] );
$FTGsoftGoods = DoStripSlashes( $_POST['softGoods'] );
$FTGgraphics = DoStripSlashes( $_POST['graphics'] );
$FTGPatentHelp = DoStripSlashes( $_POST['PatentHelp'] );
$FTGediting = DoStripSlashes( $_POST['editing'] );
$FTGComments = DoStripSlashes( $_POST['Comments'] );
$FTGaccesscode = DoStripSlashes( $_POST['accesscode'] );
$FTGsubmit = DoStripSlashes( $_POST['submit'] );
$FTGreset = DoStripSlashes( $_POST['reset'] );



$validationFailed = false;

# Fields Validations


if (!CheckString($FTGName, 1, 0, kStringRangeFrom, kNo, kNo, kNo, '', kMandatory)) { $validationFailed = true; }

if (!CheckEmail($FTGEmailFrom, kMandatory)) { $validationFailed = true; }

if (!CheckValueList_accesscode($FTGaccesscode, 1, kMandatory)) { $validationFailed = true; }



# Redirect user to the error page

if ($validationFailed === true) {

header("Location: error.html");

}

if ( $validationFailed === false ) {

# Email to Form Owner

$emailSubject = FilterCChars("The 11 Group Inquiry");

$emailBody = "Contact's Name : $FTGName\r\n"
. "Contact's Email: $FTGEmailFrom\r\n"
. "Contact's Phone : $FTGPhone\r\n"
. "I'm interested in Production Services : $FTGProductionServices\r\n"
. "I'm interested in Equip Rental : $FTGEquipRental\r\n"
. "I'm interested in videography : $FTGvideography\r\n"
. "I'm interested in marketing Distribution : $FTGmarketingDistribution\r\n"
. "I'm interested in Photo Services : $FTGPhotoServices\r\n"
. "I'm interested in soft Goods : $FTGsoftGoods\r\n"
. "I'm interested in graphics : $FTGgraphics\r\n"
. "I'm interested in Patent Help : $FTGPatentHelp\r\n"
. "I'm interested in editing : $FTGediting\r\n"
. "Comments : $FTGComments\r\n"
. "accesscode : $FTGaccesscode\r\n"
. "submit : $FTGsubmit\r\n"
. "reset : $FTGreset\r\n"
. "";
$emailTo = 'Scott <scott@designsatwork.com>';

$emailFrom = FilterCChars("$FTGEmailFrom");

$emailHeader = "From: $emailFrom\r\n"
. "MIME-Version: 1.0\r\n"
. "Content-type: text/plain; charset=\"UTF-8\"\r\n"
. "Content-transfer-encoding: 8bit\r\n";

mail($emailTo, $emailSubject, $emailBody, $emailHeader);


# Redirect user to success page

header("Location: thanks.html");

}

?>



AND the relavent form code, from http://www.designsatwork.com/the11group/contact.html AND/OR contact.php

<p><form method="POST" action="sendemail.php">
<br />
<table width="650" border="0">
<tr>
<td width="25%" rowspan="10" align="center" valign="middle"><img src="images/EmailIcon.png" alt="" width="219" height="219" /><br />
<b>THE 11 GROUP</b><br />
Las Vegas, NV 89145<br />
Phone: (702) 371-5736 <br />
Fax: (702) 254-4462 </td>
<td colspan="3" align="center">For a quote or more information on our services, please fill out the form below. Somoeone will be in touch as soon as possible.</td>
</tr>
<tr>
<td height="22">&nbsp;</td>
<td valign="bottom">Fields marked (*) are required </td>
<td>&nbsp;</td>
</tr>
<tr>
<td align="right">Your Name:* </td>
<td><input type="text" name="Name" /></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="20%" align="right">Your Email:* </td>
<td width="42%"><input type="text" name="EmailFrom" /></td>
<td width="13%">&nbsp;</td>
</tr>
<tr>
<td align="right">Your Phone:* <br /></td>
<td><input type="text" name="Phone" /></td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="92" colspan="2" align="center"><table width="85%" border="0" align="center">
<tr>
<th valign="top" scope="row"><input name="ProductionServices" type="checkbox" id="ProductionServices" value="Yes" />
</label></th>
<td valign="middle"><div align="left"> Production Services </div></td>
<th valign="top" scope="row"><div align="left">
<input name="EquipRental" type="checkbox" id="EquipRental" value="Yes" />
</div></th>
<td align="left" valign="middle">Equipment Rental</td>
</tr>
<tr>
<th valign="top" scope="row"><div align="left">
<input name="videography" type="checkbox" id="videography" value="Yes" />
</div></th>
<td valign="middle"><div align="left">
<label>Video Services</label>
</div></td>
<td valign="top"><input name="marketingDistribution" type="checkbox" id="marketingDistribution" value="Yes" /></td>
<td align="left" valign="middle">Marketing/Distribution</td>
</tr>
<tr>
<td valign="top"><div align="left">
<input name="PhotoServices" type="checkbox" id="PhotoServices" value="Yes" />
</div>
<label>
<div align="left"></div>
</label></td>
<td valign="middle"><label>Photographic Services</label></td>
<td valign="top"><input name="softGoods" type="checkbox" id="softGoods" value="Yes" /></td>
<td align="left" valign="middle">Soft Goods (hats, shirts, etc)</td>
</tr>
<tr>
<td valign="top"><input name="graphics" type="checkbox" id="graphics" value="Yes" /></td>
<td valign="middle">Graphic Design Services</td>
<td valign="top"><div align="left">
<input name="PatentHelp" type="checkbox" id="PatentHelp" value="Yes" />
</div></td>
<td align="left" valign="middle">Patent Assistance</td>
</tr>
<tr>
<td valign="top"><input name="editing" type="checkbox" id="editing" value="Yes" /></td>
<td valign="middle">Editing Services</td>
<td valign="top">&nbsp;</td>
<td align="left" valign="middle">&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="center"> What else would you like to tell us about your needs?:*</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="center"><textarea name="Comments" cols="45" rows="8">Let us know how we can be of assistance here.</textarea></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="center">To ensure your a human, what is the total of two plus 2?
<input type="text" name="accesscode" size="12"></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="center"><table width="150" border="0">
<tr>
<td align="center"><input type="submit" name="submit" value="Submit" /></td>
<td align="center"><input type="reset" name="reset" value="Reset" /></td>
</tr>
</table></td>
<td>&nbsp;</td>
</tr>
</table>
</form>