HELP with a Contact Form

I am helping a friend with her site and her contact form is not working properly. When submitting the completed form I am getting an error. Can I get some help on this? Thank you.

The page is below:

http://stilettospyschool.com/contact.php

I can see the error:

exception ‘Exception’ with message ‘You are missing your list’ in /contact.php:92 Stack trace: #0 {main}

But without being able to see the page code, I can’t tell you much.

Thanks, here is the page code.

[code]<?php

include_once(‘includes/cc_class_stiletto_contact.php’);

$ccContactOBJ = new CC_Contact();

$ccListOBJ = new CC_List();

$disabled = null;

//get all available lists for the current CC account.

$allLists = $ccListOBJ->getLists();

$msg=’’;

//if we have post fields means that the form have been submitted.

function isValidEmail($email){

return preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$^", $email);

}

function makeList($items){

//get the total number of activities (minus 1 for array purposes)

$total_items = (sizeof($items)-1);

//process all activities until total is met

for ($i=0; $i<=$total_items; $i++){

	//if the end of the activities item is equal to the current looped activity name, it doesn't need the :::

	 if (end($items) == $items[$i]){

		$last = $items[$i];	



	 //otherwise, add the :::

	 }else{

		$first .= $items[$i] . ":::";

		//echo $activities[$i] . ":::";

	 }

}

$items_list = $first . $last;

if(strlen($items_list)>50)

$items_list=substr($items_list,0,49);

return $items_list;

}

/**

  • If we have post fields means that the form have been submitted.

  • Therefore we start submiting inserted data to ConstantContact Server.

*/

try {

	if(isset($_POST["state"]) && isset($_POST["state_name"]))

	{

		if($_POST["state"] != "" && $_POST["state_name"] != "")

		{

			$_POST["state_name"] = "";

			echo "<h1><center>State Other was erased to prevent errors on submission</center></h1>";

		}

		else {

			

		}

	}

	

if (!empty($_POST)) {

	$postFields = array();

	$postFields["email_address"] = $_POST["email_address"];

	$postFields["first_name"] = $_POST["first_name"];

	$postFields["last_name"] = $_POST["last_name"];

	$postFields["middle_name"] = $_POST["middle_name"];

	$postFields["company_name"] = $_POST["company_name"];

	$postFields["job_title"]= $_POST["job_title"];

	$postFields["home_number"] = $_POST["home_num"];

	$postFields["work_number"] = $_POST["wrk_num"];

	$postFields["address_line_1"] = $_POST["adr_1"];

	$postFields["address_line_2"] = $_POST["adr_2"];

	$postFields["address_line_3"] = $_POST["adr_3"];

	$postFields["city_name"] = $_POST["city"];

	$postFields["state_code"] = $_POST["state"];

	// The Code is looking for a State Code For Example TX instead of Texas

	$postFields["state_name"] = $_POST["state_name"];

	$postFields["country_code"] = $_POST["country"];

	$postFields["zip_code"] = $_POST["postal_code"];

	$postFields["sub_zip_code"] = $_POST["sub_postal"];

	$postFields["notes"] = $_POST["notes"];

	if(isset($_POST["mail_type"]))

	{

	$postFields["mail_type"] = $_POST["mail_type"];

	}

	else

	{

		$postFields["mail_type"] = "HTML";

	}

	

	if(isset($_POST["lists"]))

	{

	$postFields["lists"] = $_POST["lists"];

	}

	else

	{

		throw new Exception("You are missing your list");

	}

	



	$postFields["custom_fields"] = array();

	foreach($_POST as $key=>$val) {

		

		if (strncmp($key, 'custom_field_', strlen('custom_field_')) === 0) {

			$postFields["custom_fields"][substr($key, strlen('custom_field_'), strlen($key)-1)] = $val;

		}

		if(is_array($val)){

			$postFields["custom_fields"][substr($key, strlen('custom_field_'), strlen($key)-1)] = makeList($val);



		}

	}

	if(trim($_POST['first_name'])=='')

		$msg="Please enter first name";

		

		if(trim($_POST['last_name'])=='' && $msg=='')

		$msg="Please enter last name";

		

		if(trim($_POST['email_address'])=='' && $msg=='')

		$msg="Please enter email";

		

		if(!isValidEmail(trim($_POST['email_address'])) && $msg==''){ 

		$msg="Please enter valid email";

		}



if($msg==''){	if($ccContactOBJ->subscriberExists($postFields["email_address"]))

		{

			$contact = $ccContactOBJ->getSubscriberDetails($postFields["email_address"]);

			$contactXML = $ccContactOBJ->createContactXML($contact['id'],$postFields);

			if (!$ccContactOBJ->editSubscriber($contact['id'], $contactXML)) {

				$error = true;

			} else {

				$error = false;

				$_POST = array();

			}



		}

		else

		{

			$contactXML = $ccContactOBJ->createContactXML(null,$postFields);



			if (!$ccContactOBJ->addSubscriber($contactXML)) {

				$error = true;

			} else {

				$error = false;

				$_POST = array();

			}

		}

}

}

	

} catch (Exception $e) {

	echo "<span style='color:red;'>" . $e . "</span>";

}







?>
Stiletto Spy School | Contact Us <?php include('includes/seo.php');?>
<div id="logo"><a href="index.php" name="logo"><img src="images/gfx-logo.jpg" alt="Stiletto Spy School"/></a></div>

<?php include('includes/navigation.php'); ?>
Read Testimonials from Stiletto Sisters
<div id="main">

  <h1 id="title">CONTACT</h1>

  <h3 id="sub-title">Obtain more information about stiletto spy school</h3>

  <!-- <p id="required">* required field</p> -->

  <div id="contact">

  <p><a href="customevents.php">Do you want to learn more about our weekend of a lifetime?</a></p>

  <?php 

  	//

  	// Here we add an area where messages  are displayed (error or success messages).

  	//



  	if (isset($error)) {

	

  		if ($error === true) {

  			$class = "error";

  			$message = $ccContactOBJ->lastError;

  		} else {

  			$class = "success";

  			$message = "Contact ".htmlspecialchars($postFields["email_address"], ENT_QUOTES, 'UTF-8')." Added.";

  		}



  		echo '<div class="'.$class.'">';

  		echo $message;

  		echo '</div>';

  	}

elseif($msg!=’’)

	{

		echo '<div class="error" style="text-align:left;font-size:13px;">';

  		echo $msg;

  		echo '</div>';

	}

	?>

  

    <form action="" method="post" id="contact-form">
<?php if($ccContactOBJ->contact_lists && !$ccContactOBJ->show_contact_lists && $ccContactOBJ->force_lists){ foreach ($allLists as $k=>$item) { echo ''; } } else { foreach ($allLists as $k=>$item) { $checked = ''; if (isset($_POST['lists'])){ if (in_array($item['id'],$_POST['lists'])) { $checked = ' checked '; } } if($ccContactOBJ->force_lists && $ccContactOBJ->show_contact_lists){ echo ''.$item['title'].'
'; } // else { // echo ' '.$item['title'].'
'; // } else { echo ' '.$item['title'].'
'; } } } ?>
      <div id="general">

      	<ul>

        	<li>

              <label for="fname">First name</label>

			  <input type="text" class="text-field" name="first_name" maxLength="50"  value="<?php  

			  			if (isset($_POST['first_name']))

			  			{

			  				echo htmlspecialchars($_POST['first_name'], ENT_QUOTES, 'UTF-8');

			  			}

			  			 ?>" />

            </li>

            <li>

              <label for="lname">Last name</label>

			  <input type="text" class="text-field" name="last_name" maxLength="50"  value="<?php  

			  			if (isset($_POST['last_name']))

			  			{

			  				echo htmlspecialchars($_POST['last_name'], ENT_QUOTES, 'UTF-8');

			  			}

			  			 ?>" />

            </li>

            <li>

              <label for="email">Email</label>

			  <input type="text" class="text-field" name="email_address" maxLength="50"  value="<?php  

			  			if (isset($_POST['email_address']))

			  			{

			  				echo htmlspecialchars($_POST['email_address'], ENT_QUOTES, 'UTF-8');

			  			}

			  			 ?>" />

            </li>

            <li>

              <label for="phone">Phone</label>

			  <input type="text" class="text-field" name="home_num" maxLength="50"  value="<?php  

			  			if (isset($_POST['home_num']))

			  			{

			  				echo htmlspecialchars($_POST['home_num'], ENT_QUOTES, 'UTF-8');

			  			}

			  			 ?>" />

            </li>

        

        </ul>

      </div>

      <div id="gender">

        <p>Gender</p>

        <ul class="checks">

          <li>

            <input type="radio" name="custom_field_1[]" id="male" value="Male" checked="checked" />

            <label for="male">Male</label>

          </li>

          <li>

            <input type="radio" name="custom_field_1[]" id="female" value="Female" />

            <label for="female">Female</label>

          </li>

        </ul>

      </div>

      <div id="age">

        <p>Age Range *</p>

        <ul class="checks">

          <li>

            <input type="radio" name="custom_field_7[]" id="under21" value="under 21" checked="checked" />

            <label for="under21">under 21</label>

          </li>

          <li>

            <input type="radio" name="custom_field_7[]" id="21to29" value="21-29" />

            <label for="21to29">21-29</label>

          </li>

          <li>

            <input type="radio" name="custom_field_7[]" id="30to39" value="30-39" />

            <label for="30to39">30-39</label>

          </li>

          <li>

            <input type="radio" name="custom_field_7[]" id="40to49" value="40-49" />

            <label for="40to49">40-49</label>

          </li>

          <li>

            <input type="radio" name="custom_field_7[]" id="50to59" value="50-59" />

            <label for="50to59">50-59</label>

          </li>

          <li>

            <input type="radio" name="custom_field_7[]" id="60plus" value="over 60" />

            <label for="60plus">60+</label>

          </li>

        </ul>

        <span id="disclaimer">(we don&rsquo;t sort groups by age, we just like to know a bit about you)</span> </div>

      <div id="interest">

        <p>Are you interested in</p>

        <ul class="checks">

          <li>

            <input type="checkbox" name="custom_field_8[]" id="nyc" value="Scheduled classes in NYC" />

            <label for="nyc">Scheduled classes in NYC</label>

          </li>

          <li>

            <input type="checkbox" name="custom_field_8[]" id="lv" value="Weekends in Las Vegas" />

            <label for="lv">Weekends in Las Vegas</label>

          </li>

          <li>

            <input type="checkbox" name="custom_field_8[]" id="private" value="Private group event/party" />

            <label for="private">Private group event/party</label>

          </li>

          <li>

            <input type="checkbox" name="custom_field_8[]" id="corporate" value="Corporate/Client Event" />

            <label for="corporate">Corporate/Client Event</label>

          </li>

        </ul>

      </div>

      <div id="availability">

        <label for="availability">We'd love to have a one on one conversation with you about our weekend long adventures. Please let us know the best way and times to reach you.</label>

        <textarea rows="3" cols="40" name="custom_field_11" id="availability"></textarea>

      </div>

      <div id="referral">

        <p>How did you hear about Stiletto Spy School?</p>

        <ul class="checks">

          <li>

            <input type="radio" name="custom_field_9[]" id="press" value="Press" />

            <label for="press">Press</label>

            <!--<label for="where">&nbsp;Where (if you remember)</label>

            <input type="text" id="where" name="where" class="text-field where"/>-->

          </li>

          <li>

            <input type="radio" name="custom_field_9[]" id="website" value="Link from another site" />

            <label for="website">Link from another site</label>

          </li>

          <li>

            <input type="radio" name="custom_field_9[]" id="friend" value="From a friend" />

            <label for="friend">From a friend</label>

          </li>

          <li>

            <input type="radio" name="custom_field_9[]" id="search" value="Search engine" />

            <label for="search">Search engine</label>

          </li>

        </ul>

      </div>

      <!--<div id="sss-friends">

        <label for="sss-friends">Do you have any friends that you&rsquo;d like us to send Stiletto Spy School information to as well? Please enter their names and email addresses here, separated with a comma:</label>

        <textarea rows="3" cols="40" name="sss-friends" id="sss-friends"></textarea>

      </div>

      <div id="mi6-friends">

        <label for="mi6-friends">Do you have any male friends that you&rsquo;d like us to send info about our brother program, MI6 Academy? Please enter their names and email addresses here, separated with a comma:</label>

        <textarea rows="3" cols="40" name="mi6-friends" id="mi6-friends"></textarea>

      </div>-->

      <div id="questions">

        <label for="questions">If you have any questions or suggestions about Stiletto Spy School, please add them below:</label>

        <textarea rows="3" cols="40" name="custom_field_10" id="questions"></textarea>

      </div>

      <input type="submit" id="btn-send" name="btn-send" value="Send" />

    </form>

  </div>

</div>
<div id="promise">

  <div class="box-small-top">

    <h2>OUR PROMISE</h2>

  </div>

  <div class="box-small-mid">

    <p>Stiletto Spy School will never sell, trade, or rent your personal information to others under any circumstances.</p>

  </div>

  <div class="box-small-end"></div>

</div>

<div id="call">

  <div class="box-small-top"></div>

  <div class="box-small-mid">

    <h3 id="call">Feel free to give us a<br />

      call at <span>(888) 779-1905</span></h3>

  </div>

  <div class="box-small-end"></div>

</div>

Copyright © 2009 Stiletto Spy School, LLC. All Rights Reserved.

<li><a href="http://www.mi6academy.com/">Men&rsquo;s MI 6 Academy</a></li>

<li>| <a href="contact.php">Contact Us</a></li>

<li>| <a href="#phone">Phone (888) 779-1905</a></li>

[/code]

OK, I assume this using some third party plug-in, possibly: http://www.constantcontact.com/uk/index.jsp, so I’m not exactly sure what the problem is, you’ll have to take a look at the documentation, but I can tell you where to look for the problem.

This will be line 92 or thereabouts:

[php]
$postFields[“lists”] = $_POST[“lists”];
}
else
{
throw new Exception(“You are missing your list”);
}
[/php]

Further down the page, under the form tag you have this:

[php]

<?php if($ccContactOBJ->contact_lists && !$ccContactOBJ->show_contact_lists && $ccContactOBJ->force_lists){ foreach ($allLists as $k=>$item) { echo ''; } } else { foreach ($allLists as $k=>$item) { $checked = ''; if (isset($_POST['lists'])){ if (in_array($item['id'],$_POST['lists'])) { $checked = ' checked '; } } if($ccContactOBJ->force_lists && $ccContactOBJ->show_contact_lists){ echo ''.$item['title'].'
'; } // else { // echo ' '.$item['title'].'
'; // } else { echo ' '.$item['title'].'
'; } } } ?>[/php]

I would try uncommenting those lines and possibly temporarily changing those fields from hidden to text, so you can see what’s in them.

Sponsor our Newsletter | Privacy Policy | Terms of Service