I have successfully used the CC Signup Form Generator to create a form integrated with my website. However, after completing the form and clicking the submit button, I always get the following:
You must enable referrer logging to use the form
You cannot send a blank form
The form data DOES get input into CC so I'm at a loss as to why this message appears rather than the "Thank You" form I specified when using the Form Generator.
Hey Pete,
Can you either give a link to your site or PM it to me. Also what version of PHP do you have and is cURL enabled?
Hy Ryan. I PMed the requested info to you the other day; did you get it?
Is there anyone out there that can help me? I'm really at an empasse and I need to get this resolved. Thanks in advance!
Hey Pete,
Can you send me the source code of ThankYou.php as I think there is something going wrong there and not on the CCSFG. The CCSFG doesent do any validation.
Here you go:
<?php
$my_email = "weddings@mountainmagnoliainn.com, innkeepers@mountainmagnoliainn.com";
/*
Enter
the continue link to offer the user after the form is sent. If you do not change this, your visitor will be given a continue link to your homepage.
If you do change it, remove the "/" symbol below and replace with the name of the page to link to, eg: "mypage.htm" or "http://www.elsewhere.com/page.htm"
*/
//
$continue = "thankyou.html";
/*
Step 3:
Save this file (ThankYou.php) and upload it together with your webpage containing the form to your webspace. IMPORTANT - The file name is case sensitive! You must save it exactly as it is named above! Do not put this script in your cgi-bin directory (folder) it may not work from there.
THAT'S IT, FINISHED!
You do not need to make any changes below this line.
*/
$errors = array();
// Remove $_COOKIE elements from $_REQUEST.
if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}
// Check all fields for an email header.
function recursive_array_check_header($element_value)
{
global $set;
if(!is_array($element_value)){if(preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i",$element_value)){$set = 1;}}
else
{
foreach($element_value as $value){if($set){break;} recursive_array_check_header($value);}
}
}
recursive_array_check_header($_REQUEST);
if($set){$errors[] = "You cannot send an email header";}
unset($set);
// Validate email field.
if(isset($_REQUEST['email']) && !empty($_REQUEST['email']))
{
if(preg_match("/(%0A|%0D|\n+|\r+|:)/i",$_REQUEST['email'])){$errors[] = "Email address may not contain a new line or a colon";}
$_REQUEST['email'] = trim($_REQUEST['email']);
if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['email']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($exploded_email[1],".") == 0){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = "Email address is invalid";}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}}
}
// Check referrer is from same site.
if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";}
// Check for a blank form.
function recursive_array_check_blank($element_value)
{
global $set;
if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}}
else
{
foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);}
}
}
recursive_array_check_blank($_REQUEST);
if(!$set){$errors[] = "You cannot send a blank form";}
unset($set);
// Display any errors and exit if errors exist.
if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;}
if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");}
// Build message.
function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");}
$message = build_message($_REQUEST);
$message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL."";
$message = stripslashes($message);
$subject = "Wedding Plans Inquiry";
$headers = "From: " . $_REQUEST['email'];
mail($my_email,$subject,$message,$headers);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><!-- InstanceBegin template="/Templates/weddings2columns.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Mountain Magnolia Inn, Suites, and Restaurant is a full service country inn located just 35 miles north of Asheville in Hot Springs, North Carolina.</title>
<meta name="Title" CONTENT="Mountain Magnolia Inn Weddings and Special Occasions in Hot Springs, NC.">
<meta name="DESCRIPTION" content="Experience the beauty and romance of a mountain wedding in Hot Springs, North Carolina. We offer a full line of wedding services including onsite catering, wedding coordinators, and spa services">
<meta name="Keywords" content="Hot Springs NC bed and breakfast, Hot Springs NC b & b, Hot Springs NC inns , Hot Springs NC restaurants, Hot Springs NC weddings, Asheville bed and breakfast, Asheville Inns, Asheville NC bed and breakfast, Asheville NC inns, Biltmore package, Biltmore, Biltmore Estate, Asheville honeymoon, Asheville NC honeymoon, NC honeymoon, North Carolina honeymoon, NC honeymoon, Asheville weddings, Asheville NC weddings, NC mountain inns, north Carolina mountain bed and breakfasts">
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
body {
background-color: #4B4D63;
color: #330;
text-align: left;
font-size: 18px;
font-weight: bold;
}
blockquote {
font-size: 16px;
text-align: left;
}
.leftheader {
font-size: 24px;
text-align: center;
}
.detailheader {
font-family: fantasy;
}
.learnmorelinks {
color: #4B4D63;
font-size: 16px;
text-align: center;
}
.learnmorelinks1 {
color: #4B4D63;
font-size: 16px;
text-align: center;
font-weight: bold;
}
.footertext { color: #2C2C58;
}
a:link {
color: #336;
font-weight: normal;
}
.thanks { text-align: center;
font-weight: normal;
}
.thanks { font-family: Verdana, Geneva, sans-serif;
}
.thanksindex {
color: #600;
}
.boldtext {
font-weight: normal;
}
.style2 {font-weight: normal; font-size: small; }
.style5 {font-size: small}
.men {
font-weight: normal;
}
-->
</style>
<title>Mountain Magnolia Historic Victorian Inn and Retreat</title>
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css">
<link href="file:///X|/POB Clients/NP/MMI/widgets/menubar/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
/* Center the text within all menu item links. This
* causes the text in menu items for both the menu bar and
* sub menus to center.
*/
ul.MenuBarHorizontal a {
text-align: center;
}
-->
</style>
</head>
<body>
<table width="923" border="0" align="center" cellspacing="5">
<tr align="center">
<td valign="top" bgcolor="#FFFFE8"><table width="911" border="0" align="center">
<tr align="center" valign="top">
<td width="908" bgcolor="#D6D6AD"><p><img src="images/header.gif" width="900" height="102" border="0" usemap="#Map7">
<ul id="Weddings" class="MenuBarHorizontal">
<li><a href="index.html">Inn Home</a> </li>
<li><a href="wedding.html">Weddings</a></li>
<li><a class="MenuBarItemSubmenu" href="#">Packages</a>
<ul>
<li><a href="wedding_large_medium.html">Large / Medium Weddings</a></li>
<li><a href="wedding_small.html">Small Weddings</a></li>
<li><a href="wedding_winter.html">Winter Weddings</a></li>
<li><a href="wedding_elopment.html">Elopements</a></li>
</ul>
</li>
<li><a href="wedding_catering.html">Catering</a></li>
<li><a href="wedding_FAQ.html">FAQ's</a></li>
<li><a href="wedding_gallery.html">Gallery</a></li>
<li><a href="wedding_availability.html">Availability</a></li>
<li><a href="wedding_contact.html">Contact Us</a></li>
</ul>
<!-- InstanceBeginEditable name="Image" -->
<table width="100%" border="0">
<tr></tr>
<tr>
<td align="center" valign="middle"><img src="images/weddinglg.jpg" width="900" height="434"></td>
</tr>
</table>
<!-- InstanceEndEditable -->
</td>
</tr>
</table>
<table width="911" border="0" cellspacing="5">
<tr>
<td width="258" align="center" valign="top" bgcolor="#938C60"><br>
<!-- InstanceBeginEditable name="SideBar" -->
<h2 class="thanks">Thank You!</h2>
<p><img src="images/wedding1_fit.jpg" width="234" height="356"></p>
<!-- InstanceEndEditable --></td>
<td valign="top"><!-- InstanceBeginEditable name="Content1" -->
<p> </p>
<div>
<center>
<p><b><strong class="leftheader"><em>Thank you for taking the time to share your wedding plan information. We will get back to you with details about availability and pricing as soon as possible.</em></strong> </p>
<?php print stripslashes($_REQUEST['name']); ?><br>
</p>
<p> </p>
</center>
</div>
<p> </p>
<!-- InstanceEndEditable --></td>
</tr>
</table>
<table width="907" height="117" border="0">
<tr>
<td width="901" align="center" bgcolor="#8C8EA8"><a href="http://www.mountainmagnoliainn.com/history.html" target="_self"><br>
History</a> | <a href="http://www.mountainmagnoliainn.com/press.html" target="_self">Press</a> | <a href="http://www.mountainmagnoliainn.com/directions.html" target="_self">Directions</a> | <a href="http://www.mountainmagnoliainn.com/links.html" target="_self">Links</a> | <a href="http://www.mountainmagnoliainn.com/green.html" target="_self">Green Practices</a> | <a href="http://www.mountainmagnoliainn.com/policies.html" target="_self">Policies</a><br />
<span class="footertext">1-800-914-9306 or 1-828-622-3543<br>
<br>
Photos by Harry Burris,
Mary Helen Wheeler, and Dorinda Doss<br>
<br>
</span></td>
</tr>
</table></td>
</tr>
</table>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-1343746-1");
pageTracker._trackPageview();
} catch(err) {}</script>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<map name="Map7">
<area shape="rect" coords="444,73,643,102" href="http://www.mountainmagnoliainn.com/availability.html" target="_self" alt="availability"><area shape="rect" coords="682,76,822,101" href="http://www.mountainmagnoliainn.com/reservations.html"" target="_self" alt="reservations">
<area shape="rect" coords="647,12,753,32" href="http://www.mountainmagnoliainn.com/gift.html" target="_blank" alt="Gift Certificates">
<area shape="rect" coords="518,12,641,32" href="http://visitor.r20.constantcontact.com/d.jsp?llr=p6fn8wbab&p=oi&m=1101352310703" target="_blank" alt="Mailing List">
</map>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-1343746-1");
pageTracker._trackPageview();
} catch(err) {}
var MenuBar1 = new Spry.Widget.MenuBar("Weddings", {imgDown:"../SpryAssets/SpryMenuBarDownHover.gif", imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
</script>
</body>
<!-- InstanceEnd --></html>
Hey Pete,
The errors are not from the CCSFG, they are coming from your validation.
if(!$set){$errors[] = "You cannot send a blank form";}
From as far as I can see this is going to bet set to true anytime errors are passed in through your validation. I would suggest doing the validation on the client side using javascript instead of catching them by the server.
Thanks for getting back to me so quickly but I'm not sure how to go about what you suggest. If I recall (and this was some time ago), I copied the "Thank You" text from the form generator...
Wait... on second thought, maybe i didn't get that from CC... let me see what else i can come up with. In the interim, if you have other suggestions, that would be great!
Yeah that code didnt come from us, we only give you the HTML for the forms and the forms link to a behind the scenes link that post it to your account. We dont do any validation what so ever. That looks code will generate an email to be sent out it looks like.
Sorry about that... Juggling too many projects and suffering from CRS... Hopefully I'll have this resolved tomorrow!
No problem Pete, let me know if you need anymore help.
Not sure if this is the right area to ask a question Ryan as I am new here, but I was wondering if theres a way to validate the fields in a form using Ajax / js. I'm not a programming so I'm a little stuff. Your help is greatly appreciated Ryan. Thanks!
The form which we provide as the result of using the CCSFG is a standard HTML form. As such, you can add any JavaScript you'd like to the form for any pre-submission validation. It would be added the same way you'd add to any form on any other HTML page.
I tried using the generated code and it works but also gives these error messages at the top of the "success" page. These code segments have to do with generating an array of my CC lists but I don't know how to correct it. Thanks for any help. -Beth
Warning: Invalid argument supplied for foreach() in /home/peoplefi/public_html/temp/CCSFG_0.0.6/cc_class.php on line 137
Warning: Invalid argument supplied for foreach() in /home/peoplefi/public_html/temp/CCSFG_0.0.6/cc_class.php on line 149
Hello,
The lines indicated in those warnings are for foreach loops used to get the contact list page links, which can be used to request additional pages (pages of up to 50 are returned with each API request), and the ID and title of each contact list.
This function is called from the index.php file in the signup folder of your CCSFG installation after the form is submitted.
The only argument passed into these foreach loops are objects from the simpleXML object that is created within the same getLists() function when the XML response that contains the data for your lists is parsed (at line 134 in the cc_class.php library).
It may be helpful to learn what is being passed into these foreach loops, by adding some code between lines 135 and 137 to echo the contents of the object to your browser. For example,
var_dump($parsedReturn);
or
echo '<pre>'; print_r($parsedReturn); echo '</pre>';
If the API request was not successful, this may dump any errors that are being returned, and help determine what's causing the issue.
Cheers,