, Guest!
Already a Member? Login or Register.

Menu



Showcase


Due to the volume of spam happening on our forums, posting is now restricted to verified members only.  If you're not verified, drop us a note with your username.

Home > FlexCMS Support Forum > User Help > FAQ's: Contact Form > Updated Contact Form Code From FlexCMS v2.5

FlexCMS Support Forum


Updated Contact Form Code From FlexCMS v2.5
Started July 11, 2007 @ 9:51pm by DCSun
(This thread is currently Locked) 
DCSun
Administrator



Posts: 625
 
Updated Contact Form Code From FlexCMS v2.5July 11, 2007 @ 9:51pm
This updated code is exactly as provided with the full install version of FlexCMS v2.5, for those using older versions or upgrading to 2.5 on existing sites. The purpose of this update is to provide some spam blocking functions.

You can also use this code if you've accidentally deleted one or both of your contact pages, and need to re-create them.


To use these new versions simply edit your contact and contact-submit pages, replacing their contents with the following. If you're re-creating the page, be sure to enable PHP (both contact and contact-submit).


contact

Code

print 'Please contact us using the form below, and we\'ll get back to you as soon as possible.<br><br>
NOTE: All fields are required.<br><br>';


$JSCode[1] = 'document.forms["SubmitForm"].elements["A4"].value = (parseInt(document.forms["SubmitForm"].elements["A2"].value) *parseInt(document.forms["SubmitForm"].elements["A3"].value)); document.forms["SubmitForm"].elements["A5"].value = (parseInt(document.forms["SubmitForm"].elements["A2"].value) +parseInt(document.forms["SubmitForm"].elements["A3"].value));';
$JSCode[2] = 'document.forms["SubmitForm"].elements["A4"].value = (parseInt(document.forms["SubmitForm"].elements["A2"].value) -parseInt(document.forms["SubmitForm"].elements["A3"].value)); document.forms["SubmitForm"].elements["A5"].value = (parseInt(document.forms["SubmitForm"].elements["A2"].value) +(parseInt(document.forms["SubmitForm"].elements["A3"].value) *parseInt(document.forms["SubmitForm"].elements["A2"].value)));';
$JSCode[3] = 'document.forms["SubmitForm"].elements["A4"].value = (parseInt(document.forms["SubmitForm"].elements["A2"].value) *parseInt(document.forms["SubmitForm"].elements["A2"].value)*parseInt(document.forms["SubmitForm"].elements["A3"].value)); document.forms["SubmitForm"].elements["A5"].value = (parseInt(document.forms["SubmitForm"].elements["A3"].value) *parseInt(document.forms["SubmitForm"].elements["A3"].value));';
$JSCode[4] = 'document.forms["SubmitForm"].elements["A4"].value = (Math.pow(parseInt(document.forms["SubmitForm"].elements["A2"].value),2)); document.forms["SubmitForm"].elements["A5"].value = (Math.floor(Math.PI*parseInt(document.forms["SubmitForm"].elements["A2"].value)));';
$JSCode[5] = 'document.forms["SubmitForm"].elements["A4"].value = ((parseInt(document.forms["SubmitForm"].elements["A2"].value) *parseInt(document.forms["SubmitForm"].elements["A3"].value))-parseInt(document.forms["SubmitForm"].elements["A2"].value)); document.forms["SubmitForm"].elements["A5"].value = ((parseInt(document.forms["SubmitForm"].elements["A2"].value) *47)+parseInt(document.forms["SubmitForm"].elements["A3"].value));';

$A1 = rand(1,5); $A2 = rand(10,99); $A3 = rand(100,999);

$A6 = intval(time()/60/60/24);
$A7 = substr($Settings['lks'],10,5);


print '<form name="SubmitForm" action="'.$MainURL.'/pages/contact-submit" method="post"><TABLE cellSpacing=0 cellPadding=0 border=0>
<TR>
<TD align=left width=105><STRONG><font face="'.$FontFace.'" size="'.$FontSize.'">Name:</font></STRONG></TD>
<TD width="452"><INPUT class=textbox maxLength=50 size=30
name="name" style="'.$FormStyle.'"></TD></TR>
<TR>
<TD align=left width=105><STRONG><font face="'.$FontFace.'" size="'.$FontSize.'">Email:</font></STRONG></TD>
<TD width="452"><INPUT class=textbox maxLength=50 size=30
name="email" style="'.$FormStyle.'"></TD></TR>
<TR>
<TD vAlign=top align=left width="105"><STRONG><font face="'.$FontFace.'" size="'.$FontSize.'">Message:</font></STRONG></TD>
<TD vAlign=top width="452"><TEXTAREA id=message name="message" rows=10 cols=35 style="'.$FormStyle.'"></TEXTAREA><BR></TD></TR>
<TR>
<TD align=left width=105><font face="'.$FontFace.'" size="'.$FontSize.'"> </font></TD>
<TD width="452"><br><font face="'.$FontFace.'" size="'.$FontSize.'"><br><br><INPUT class=submit type="submit" value="Submit Form" name="submit" style="'.$FormStyle.'"><input type="hidden" name="A1" value="'.$A1.'"><input type="hidden" name="A2" value="'.$A2.'"><input type="hidden" name="A3" value="'.$A3.'"><input type="hidden" name="A4" value=""><input type="hidden" name="A5" value=""><input type="hidden" name="A6" value="'.dechex($A6).'"><input type="hidden" name="A7" value="'.$A7.'"><script>'.$JSCode[$A1].'</script><noscript><br><br><b>JavaScript MUST be enabled for this form to function. You are seeing this message because JavaScript is NOT currently enabled on your system.</b><br><br></noscript></form></font></TD></TR></TABLE>';



contact-submit

Code

ReadFormArguments();
Global $FormArguments;

foreach ($FormArguments as $Key=>$Value){
$FormArguments[$Key] = stripslashes($FormArguments[$Key]);
}

$FormArguments['name'] = VerifyCleanString($FormArguments['name'],2);
$FormArguments['email'] = VerifyCleanString($FormArguments['email'],1);



$FormValidated1 = false;
if ($FormArguments['A1'] == 1) {
if (($FormArguments['A4'] == ($FormArguments['A2']*$FormArguments['A3'])) && ($FormArguments['A5'] == ($FormArguments['A2']+$FormArguments['A3']))) {
$FormValidated1 = true;
}
}
else if ($FormArguments['A1'] == 2) {
if (($FormArguments['A4'] == ($FormArguments['A2']-$FormArguments['A3'])) && ($FormArguments['A5'] == ($FormArguments['A2']+($FormArguments['A3']*$FormArguments['A2'])))) {
$FormValidated1 = true;
}
}
else if ($FormArguments['A1'] == 3) {
if (($FormArguments['A4'] == ($FormArguments['A2']*$FormArguments['A2']*$FormArguments['A3'])) && ($FormArguments['A5'] == ($FormArguments['A3']*$FormArguments['A3']))) {
$FormValidated1 = true;
}
}
else if ($FormArguments['A1'] == 4) {
if (($FormArguments['A4'] == ($FormArguments['A2']*$FormArguments['A2'])) && ($FormArguments['A5'] == floor(M_PI*$FormArguments['A2']))) {
$FormValidated1 = true;
}
}
else if ($FormArguments['A1'] == 5) {
if (($FormArguments['A4'] == ($FormArguments['A2']*$FormArguments['A3'])-$FormArguments['A2']) && ($FormArguments['A5'] == ($FormArguments['A2']*47)+$FormArguments['A3'])) {
$FormValidated1 = true;
}
}

$FormValidated2 = false;
if (hexdec($FormArguments['A6']) <= (intval(time()/60/60/24)+2) && $FormArguments['A7'] == substr($Settings['lks'],10,5)) {
$FormValidated2 = true;
}


if ($FormArguments['name'] != '' && $FormArguments['email'] != '' && $FormArguments['message'] != '' && $FormValidated1 == true && $FormValidated2 == true) {

$MailTo = $Settings['ContactEmail'];
$MailTitle = $Settings['SiteName'].' Web Form';
$MailFrom = 'From: '.$FormArguments['name'].' <'.$FormArguments['email'].'>';
$MailMessage = $FormArguments['message'];

mail($MailTo,$MailTitle,$MailMessage,$MailFrom);


print 'Your message has been sent. Thank you for contacting us.';

}
else {

print 'All required fields were not filled. Please complete the information requested.<br><br>NOTE: All fields are required.';


$JSCode[1] = 'document.forms["SubmitForm"].elements["A4"].value = (parseInt(document.forms["SubmitForm"].elements["A2"].value) *parseInt(document.forms["SubmitForm"].elements["A3"].value)); document.forms["SubmitForm"].elements["A5"].value = (parseInt(document.forms["SubmitForm"].elements["A2"].value) +parseInt(document.forms["SubmitForm"].elements["A3"].value));';
$JSCode[2] = 'document.forms["SubmitForm"].elements["A4"].value = (parseInt(document.forms["SubmitForm"].elements["A2"].value) -parseInt(document.forms["SubmitForm"].elements["A3"].value)); document.forms["SubmitForm"].elements["A5"].value = (parseInt(document.forms["SubmitForm"].elements["A2"].value) +(parseInt(document.forms["SubmitForm"].elements["A3"].value)*parseInt(document.forms["SubmitForm"].elements["A2"].value)));';
$JSCode[3] = 'document.forms["SubmitForm"].elements["A4"].value = (parseInt(document.forms["SubmitForm"].elements["A2"].value) *parseInt(document.forms["SubmitForm"].elements["A2"].value) *parseInt(document.forms["SubmitForm"].elements["A3"].value)); document.forms["SubmitForm"].elements["A5"].value = (parseInt(document.forms["SubmitForm"].elements["A3"].value)*parseInt(document.forms["SubmitForm"].elements["A3"].value));';
$JSCode[4] = 'document.forms["SubmitForm"].elements["A4"].value = (Math.pow(parseInt(document.forms["SubmitForm"].elements["A2"].value),2)); document.forms["SubmitForm"].elements["A5"].value = (Math.floor(Math.PI*parseInt(document.forms["SubmitForm"].elements["A2"].value)));';
$JSCode[5] = 'document.forms["SubmitForm"].elements["A4"].value = ((parseInt(document.forms["SubmitForm"].elements["A2"].value) *parseInt(document.forms["SubmitForm"].elements["A3"].value)) -parseInt(document.forms["SubmitForm"].elements["A2"].value)); document.forms["SubmitForm"].elements["A5"].value = ((parseInt(document.forms["SubmitForm"].elements["A2"].value) *47)+parseInt(document.forms["SubmitForm"].elements["A3"].value));';

$A1 = rand(1,5); $A2 = rand(10,99); $A3 = rand(100,999);

$A6 = intval(time()/60/60/24);
$A7 = substr($Settings['lks'],10,5);


print '<br><br><form name="SubmitForm" action="'.$MainURL.'/pages/contact-submit" method="post"><TABLE cellSpacing=0 cellPadding=0 border=0>
<TR>
<TD align=left width=105><STRONG><font face="'.$FontFace.'" size="'.$FontSize.'">Name:</font></STRONG></TD>
<TD width="452"><font face="'.$FontFace.'" size="'.$FontSize.'"><INPUT class=textbox maxLength=50 size=30
name="name" style="'.$FormStyle.'" value="'.str_replace('"','&'.'#34;',$FormArguments['name']).'"></font></TD></TR>
<TR>
<TD align=left width=105><STRONG><font face="'.$FontFace.'" size="'.$FontSize.'">Email:</font></STRONG></TD>
<TD width="452"><font face="'.$FontFace.'" size="'.$FontSize.'"><INPUT class=textbox maxLength=50 size=30
name="email" style="'.$FormStyle.'" value="'.str_replace('"','&'.'#34;',$FormArguments['email']).'"></font></TD></TR>
<TR>
<TD vAlign=top align=left width="105"><STRONG><font face="'.$FontFace.'" size="'.$FontSize.'">Message:</font></STRONG></TD>
<TD vAlign=top width="452"><font face="'.$FontFace.'" size="'.$FontSize.'"><TEXTAREA id=message name="message" rows=10 cols=35 style="'.$FormStyle.'">'.str_replace('<','&l'.'t;',$FormArguments['message']).'</TEXTAREA><BR>
</font> </TD></TR>
<TR>
<TD vAlign=top align=left width=105><font face="'.$FontFace.'" size="'.$FontSize.'"> </font></TD>
<TD width="452"><br><font face="'.$FontFace.'" size="'.$FontSize.'"><br><br><INPUT class=submit type="submit" value="Submit Form" name="submit" style="'.$FormStyle.'"><input type="hidden" name="A1" value="'.$A1.'"><input type="hidden" name="A2" value="'.$A2.'"><input type="hidden" name="A3" value="'.$A3.'"><input type="hidden" name="A4" value=""><input type="hidden" name="A5" value=""><input type="hidden" name="A6" value="'.dechex($A6).'"><input type="hidden" name="A7" value="'.$A7.'"><script>'.$JSCode[$A1].'</script><noscript><br><br><b>JavaScript MUST be enabled for this form to function. You are seeing this message because JavaScript is NOT currently enabled on your system.</b><br><br></noscript></form></font></TD></TR></TABLE>';

}



FlexCMS v3.2 Has Been Released!
 

Last Edit: September 6, 2008 @ 3:34pm by DCSun

(This thread is currently Locked) 




Try & Buy FeedForAll - Easy to use RSS Feed Creator - great for iTunes users!

MEMBERS




All Contents, Code, Scripts and Technologies Copyright 2003-2009 FlexCMS.
All Rights Reserved. Software License Agreement

Processing Time: 0.12086 seconds.
 
Management Login

Powered By FlexCMS
Powered By FlexCMS