cancel
Showing results for 
Search instead for 
Did you mean: 

Create a signup form that limits user to one list

Frequent Participant

He just gave you a link to

He just gave you a link to the sample forms, if you understand PHP or .NET you'll be able to modify those samples to do what you need really quickly.


See add_contact.php lines 195 - 215


That contains the list selection code, all you need to do is hide that bit then add a hidden form field here with the contact list ID of the list you want to subscribe your users to.


Hope that helps.

James Benson, PHP Developer.


Constant Contact Services: http://integrationservic.es/

Occasional Participant

Hi James

James, we are not tech-guys, I wish i was.  I need a step-by step way to do this.  For example: whats a hidden form field!  Just need: A B C D.  Thanks for your patience.


 

Frequent Participant

Hi, You can add a simple

Hi,


You can add a simple signup form with (or possibly without) a list selection to your website using your constant contact account,  it's a simple job of copying and pasting some code, however if you need certain functionality you cannot get using this method you need to use the API.


Sorry maybe I misunderstood, if your looking for a custom signup form that uses the API and do not have any programming experience of any sort you will need someone to do it for you.

James Benson, PHP Developer.


Constant Contact Services: http://integrationservic.es/

Occasional Participant

Let's try this question one more time

 I do understand HTML and PHP -- the examples were of no use. 


Here's the problem -- I go to the signup form wizard, and Step 1 allows me to choose the style of form. Step 2 allows me to edit fonts and colors. Step 3 gives me the HTML code. I don't see anything else.


How -- please! -- do I get the form to target one particular list. As it stands, I can choose which lists show up when the user submits the form and gets to the CC website via the "Edit Your Join My Mailing List Form" page under "Lists", and which list is chosen by default. But these are global choices. I want my user to see a different list checked, depending on which of my forms they have submitted.


Surely there has to be a simple answer to this question. A hidden field perhaps, but how to know what the value of the field should be?


Thanks,


=vg

Frequent Participant

You will need to use the API

You will need to use the API and a custom signup form to do this.


I've edited the add_contact.php example and posted it below, this should do what you need I think?


All you need to do here is edit line 191 and change YOUR_CONTACT_LIST_ID to the ID of your own contact list.


<?php



include_once('cc_class.php');







$ccOBJ = new ConstantContact();











/**



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



 * Therefore we start submiting inserted data to ConstantContact Server.



 */



if (!empty($_POST)) {



    $postFields = array();







    $postFields = $_POST;



    $postFields = $_POST;



    $postFields = $_POST;



    $postFields = $_POST;



    $postFields = $_POST;



    $postFields= $_POST;   



       



    $postFields = $_POST;



    $postFields = $_POST;



   



    $postFields = $_POST;



    $postFields = $_POST;



    $postFields = $_POST;



    $postFields = $_POST;



    $postFields = $_POST;  // The Code is looking for a State Code For Example TX instead of Texas



    $postFields = $_POST;



    $postFields = $_POST;



    $postFields = $_POST;



    $postFields = $_POST;   



    $postFields = $_POST;



    $postFields = $_POST;   



   



    $postFields = $_POST;







    $postFields = array();



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



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



            $postFields = $val;



        }



    }



   



   



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



   



       



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



        $error = true;



    }



    else {



        $error = false;



        $_POST = array();       



    }



   



}















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



$allLists = $ccOBJ->getLists();



//get all available states



$allStates = $ccOBJ->getStates();



//get all available countries



$allCountries = $ccOBJ->getCountries();







?>











<?php include_once('header.php');?>







<div align="center" style="width: 900px;">



<h2>Add a new Subscriber - Full form</h2>



<?php



//



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



//



    if (isset($error)) {



        if ($error === true) {



            $class = "error";



            $message = $ccOBJ->lastError;    



        }



        else {



            $class = "success";



            $message = "Contact ".$_POST." Added.";



        }



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



        echo $message;



        echo '</div>';



    }



?>







<form action="" method="post">



<div style="float: right; text-align: left; overflow: auto; height: 640px; width:250px;">



<input type="hidden" name="lists[]" value="YOUR_CONTACT_LIST_ID" />

<!--

    <fieldset>



        <legend> Interests list </legend>



    <?php



        foreach ($allLists as $k=>$item) {



            $checked = '';   



            if($_POST){



            if (in_array($item,$_POST)) {



                $checked = ' checked ';



            }



            }



            echo '<input type="checkbox" '.$checked.' class="checkbox" name="lists[]" value="'.$item.'" id="chk_'.$k.'" /> <label for="chk_'.$k.'">'.$item.'</label><br/>';



        }



    ?>       



    </fieldset>

-->



</div>   



<div>







    <h3>Contact information</h3>   



    <table width="580" border="0" cellpadding="2" cellspacing="0">



        <tr>



            <td align="left">Email Address:</td>



            <td align="left"><input type="text" name="email_address" value="<?php echo $_POST?>" maxLength="100" /></td>



            <td align="left">&nbsp;</td>



              <td align="left">&nbsp;</td>



      </tr>



        <tr>



            <td align="left">First Name:</td>



            <td align="left"><input type="text" name="first_name" maxLength="100"  value="<?php echo $_POST?>" /></td>



            <td align="left">Last Name:</td>



            <td align="left"><input type="text" name="last_name" maxLength="100"  value="<?php echo $_POST?>" /></td>



        </tr>



        <tr>



            <td align="left">Middle Name:</td>



            <td align="left"><input type="text" name="middle_name" maxLength="100"  value="<?php echo $_POST?>" /></td>



            <td align="left">Home phone:</td>



            <td align="left"><input type="text" name="home_num" maxLength="100"  value="<?php echo $_POST?>" /></td>



        </tr>



        <tr>



            <td align="left" valign="top">Address:</td>



            <td align="left" colspan="3">



                <input type="text" name="adr_1" maxLength="100" style="width: 440px"  value="<?php echo $_POST?>" /><br/>



                <input type="text" name="adr_2" maxLength="100" style="width: 440px" value="<?php echo $_POST?>" /><br/>



                <input type="text" name="adr_3" maxLength="100" style="width: 440px" value="<?php echo $_POST?>" /><br/>



            </td>



        </tr>



        <tr>



            <td align="left">City:</td>



            <td align="left"><input type="text" name="city" maxLength="100"  value="<?php echo $_POST?>" /></td>



            <td align="left">State:</td>



            <td align="left">



                <select name="state">



                <option value="">&nbsp;</option>



                <?php                



                foreach ($allStates as $stateCode=>$stateName) {



                    $selected = '';



                    if ($stateCode == $_POST) {



                        $selected = ' selected ';



                    }



                    echo '<option value="'.$stateCode.'" '.$selected.'>'.$stateName.'</option>';



                }



                ?>



                </select>



            </td>



        </tr>



        <tr>



            <td align="left">Zip:</td>



            <td align="left"><input type="text" name="postal_code" maxLength="100" value="<?php echo $_POST?>"/></td>



            <td align="left">State (Other):</td>



            <td align="left"><input type="text" name="state_name" maxLength="100" value="<?php echo $_POST?>"/></td>



        </tr>



        <tr>



            <td align="left">Sub-zip:</td>



            <td align="left"><input type="text" name="sub_postal" maxLength="100" value="<?php echo $_POST?>"/></td>



            <td align="left">Country:</td>



            <td align="left">



            <select name="country" maxLength="100">



                <option value="">&nbsp;</option>



            <?php



                foreach ($allCountries as $countryCode=>$countryName) {



                    $selected = '';



                    if ($countryCode == $_POST) {



                        $selected = ' selected ';



                    }



                    echo '<option value="'.$countryCode.'" '.$selected.'>'.$countryName.'</option>';   



                }



            ?>



            </select>



            </td>



            <td colspan="2"></td>



        </tr>



        <tr>



            <td align="left">E-Mail Type:</td>



            <td align="left" colspan="3">



                <input type="radio" class="checkbox" name="mail_type" id="mt1" value="HTML" <?php echo ($_POST=='HTML' || empty($_POST))?' checked ':'';?> />



                <label for="mt1">HTML</label>



                &nbsp;or&nbsp;



                <input type="radio" class="checkbox" name="mail_type" id="mt2" value="Text" <?php echo ($_POST=='Text')?' checked ':'';?> />



                <label for="mt2">Text</label>



            </td>           



        </tr>



    </table>



           



    <h3>Work details</h3>



    <table width="580" border="0" cellpadding="2" cellspacing="0">



        <tr>



            <td align="left">Company Name:</td>



            <td align="left"><input type="text" name="company_name" maxLength="100"  value="<?php echo $_POST?>" /></td>



            <td align="left">Job Title:</td>



            <td align="left"><input type="text" name="job_title" maxLength="100"  value="<?php echo $_POST?>" /></td>



        </tr>



        <tr>



            <td align="left">Work phone:</td>



            <td align="left"><input type="text" name="wrk_num" maxLength="100"  value="<?php echo $_POST?>" /></td>



            <td colspan="2"></td>



        </tr>



    </table>



    <h3>Custom Fields & Notes</h3>



    <table width="580" border="0" cellpadding="2" cellspacing="0">



        <tr>



            <td align="left">Custom Field 1:</td>



            <td align="left"><input type="text" name="custom_field_1" maxLength="100"  value="<?php echo $_POST?>" /></td>



            <td align="left">Custom Field 2:</td>



            <td align="left"><input type="text" name="custom_field_2" maxLength="100"  value="<?php echo $_POST?>" /></td>



        </tr>



        <tr>



            <td align="left">Custom Field 3:</td>



            <td align="left"><input type="text" name="custom_field_3" maxLength="100"  value="<?php echo $_POST?>" /></td>



            <td align="left">Custom Field 4:</td>



            <td align="left"><input type="text" name="custom_field_4" maxLength="100"  value="<?php echo $_POST?>" /></td>



        </tr>



        <tr>



            <td align="left">Custom Field 5:</td>



            <td align="left"><input type="text" name="custom_field_5" maxLength="100"  value="<?php echo $_POST?>" /></td>



            <td align="left">Custom Field 6:</td>



            <td align="left"><input type="text" name="custom_field_6" maxLength="100"  value="<?php echo $_POST?>" /></td>



        </tr>



        <tr>



            <td align="left">Custom Field 7:</td>



            <td align="left"><input type="text" name="custom_field_7" maxLength="100"  value="<?php echo $_POST?>" /></td>



            <td align="left">Custom Field 8:</td>



            <td align="left"><input type="text" name="custom_field_8" maxLength="100"  value="<?php echo $_POST?>" /></td>



        </tr>



        <tr>



            <td align="left">Custom Field 9:</td>



            <td align="left"><input type="text" name="custom_field_9" maxLength="100"  value="<?php echo $_POST?>" /></td>



            <td align="left">Custom Field 10:</td>



            <td align="left"><input type="text" name="custom_field_10" maxLength="100"  value="<?php echo $_POST?>" /></td>



        </tr>



        <tr>



            <td align="left">Custom Field 11:</td>



            <td align="left"><input type="text" name="custom_field_11" maxLength="100"  value="<?php echo $_POST?>" /></td>



            <td align="left">Custom Field 12:</td>



            <td align="left"><input type="text" name="custom_field_12" maxLength="100"  value="<?php echo $_POST?>" /></td>



        </tr>



        <tr>



            <td align="left">Custom Field 13:</td>



            <td align="left"><input type="text" name="custom_field_13" maxLength="100"  value="<?php echo $_POST?>" /></td>



            <td align="left">Custom Field 14:</td>



            <td align="left"><input type="text" name="custom_field_14" maxLength="100"  value="<?php echo $_POST?>" /></td>



        </tr>



        <tr>



            <td align="left">Custom Field 15:</td>



            <td align="left"><input type="text" name="custom_field_15" maxLength="100"  value="<?php echo $_POST?>" /></td>



            <td align="left"></td>



            <td align="left"></td>



        </tr>



        <tr>



            <td align="left">Notes:</td>



            <td align="left" colspan="3">



            <textarea rows="8" cols="50" name="notes"><?php echo htmlspecialchars($_POST)?></textarea>



            </td>



        </tr>



        <tr>



            <td align="center" colspan="4">                 



                <input type="submit" name="submit" value="Add Contact" />



            </td>



        </tr>



    </table>



</div>



</form>



</div>


 

James Benson, PHP Developer.


Constant Contact Services: http://integrationservic.es/

Frequent Participant

@victorgrey Please start your

@Please start your own forum post to ask a question as your question is different your just confusing things, thanks.

James Benson, PHP Developer.


Constant Contact Services: http://integrationservic.es/

New Member

     

 


 


 

Pamela

New Member

Create a signup form that limits user to one list

I'm new to this API stuff so I aplolgize for my little knowledge.  I've downloaded the "cc_class.php" script and made the changes to reflect the lists I want users to see.  I also added my sign in, password and key code as well.   What I don't know is what is the next step?  Where do I put this script - in my web page, or do I upload it and link to it, or what?  And how does it link to the subscribe here button on my site.


Thanks for the help.


Pamela

Pamela

CTCT Employee

Pamela,   Now that you have

Pamela,


 


Now that you have modified the cc_class.php file you will need to upload that, along with the following files, into a single directory:


1: A form to collect the data such as the included add_contact.php, simple_form.php, or your own custom form.

2: contries.txt

3: states.txt

4: styles.css


 


Once you have uploaded those files into a single directory on your webserver you should be able to access the form and submit the information.


 


Please try those steps and feel free to ask any additional questions.


 

Dan H

Support Engineer, Constant Contact

Occasional Participant

Single List Subscription

Hi,


I'm trying to use the sample code to create a single list subscription form but it isn't working. I've pared the form down to just the subscribers email address and mailing preference.  I included a hidden field for the list I want to use (#32).  When I submit the form, all I get back is a generic "An Error Occurred".  How can I find what the error is?


If it helps, here's my form:


<form action="" method="post">

<div style="float: right; text-align: left; overflow: auto; height: 640px; width:250px;">

<input type="hidden" name="lists[]" value="32" />  <?php // List# for Yellow Pages ?>

</div>  



<div>

<h3>Contact information</h3>  



<table width="580" border="0" cellpadding="2" cellspacing="0">

 <tr>

  <td align="left">Email Address:</td>

  <td align="left"><input type="text" name="email_address" value="<?php echo $postFields?>" maxLength="100" /></td>

  <td align="left">&nbsp;</td>

  <td align="left">&nbsp;</td>

 </tr>

 <tr>

  <td align="left">E-Mail Type:</td>

  <td align="left" colspan="3">

   <input type="radio" class="checkbox" name="mail_type" id="mt1" value="HTML" <?php echo ($postFields == 'HTML' || $postFields == '') ? ' checked ' : '';?> />

   <label for="mt1">HTML</label>

   &nbsp;or&nbsp;

   <input type="radio" class="checkbox" name="mail_type" id="mt2" value="Text" <?php echo ($postFields == 'Text') ? ' checked ' : '';?> />

   <label for="mt2">Text</label>

  </td>

 </tr>

 <tr>

  <td align="center" colspan="4">

   <input type="submit" name="submit" value="Add Contact" />

  </td>

 </tr>

</table>



</div>

</form>

 


Thanks,


Gary