Drop Down in Newsletter Subscribe

By KCMedia - April 18, 2013

Hi

We have this subscribe to newsletter setup that is using the newsletter plugin but i have every other field working other than the drop down field putting the data into the subscribers fields in the cmsb

here is the code i dont know why it wont put the data into the field but the drop down works and displays the data and populates the dropdown from the cmsb but just work submit into DB.

<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/var/www/html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  $errorsAndAlerts = "";
    
  // load newsletter settings
  $newsletterSettings = mysql_get('_nlb_settings', 1);

  if (@$_REQUEST['submitForm']) {

    // error checking
    if (!@$_REQUEST['name'])             { $errorsAndAlerts .= "You must enter your name!<br/>\n"; }
    if (!@$_REQUEST['postcode'])         { $errorsAndAlerts .= "You must enter your post code!<br/>\n"; }
    if (!@$_REQUEST['email'])            { $errorsAndAlerts .= "No email address specified!<br/>\n"; }
    if (!@$_REQUEST['hear_about'])        { $errorsAndAlerts .= "You must select how you found the site!<br/>\n"; }
    elseif (!isValidEmail($_REQUEST['email'])) { $errorsAndAlerts .= "Invalid email specified, email must be in the format: user@example.com<br/>\n"; }
    
    

    //
    if (!$errorsAndAlerts) {

      // convert "Display Name" <local-part@domain> to local-part@domain
      $_REQUEST['email'] = array_value(isValidEmail($_REQUEST['email']), 0, 0);
      $subscriber    = mysql_get('_nlb_subscribers', null, array('email' => $_REQUEST['email']));

      // create subscriber if they don't already exist
      if (!$subscriber) {
        $authkey      = _nlb_generateAuthKey();
        $colsToValues = array('name' => $_REQUEST['name'], 'postcode' => $_REQUEST['postcode'], 'email' => $_REQUEST['email'], 'hear_about' => $_REQUEST['hear_about'], 'authkey' => $authkey);
        $recordNum    = mysql_insert('_nlb_subscribers', $colsToValues, true);
        $subscriber   = mysql_get('_nlb_subscribers', $recordNum);
      }

      // send message & show alert
      $errorsAndAlerts = '';
      if ($subscriber['confirmed']) {
        $errorsAndAlerts = "You're already subscribed to this newsletter.<br/>\n";
      }
      else {
        nlb_log('0', $subscriber['num'], '1');

        $to                 = $subscriber['email'];
        $newsletterSettings = mysql_get('_nlb_settings', 1);
        $mailErrors         = nlb_sendMessage($to, $newsletterSettings['confirm_subject'], $newsletterSettings['confirm_html'], $subscriber);
        if ($mailErrors) { die("Mail Error: $mailErrors"); }

        // send alert
        $errorsAndAlerts .= "";
        $errorsAndAlerts .= "";
        $_REQUEST = array(); // clear form
      }
    }
  } 
 
    
?>
<!doctype html>
<!--[if IE 7]>         <html class="lt-ie9 lt-ie8 ie7 ie" lang="en"> <![endif]-->
<!--[if IE 8]>         <html class="lt-ie9 ie8 ie" lang="en"> <![endif]-->
<!--[if IE 9]>         <html class="ie9 ie" lang="en"> <![endif]-->
<!--[if gt IE 9]><!--> <html lang="en"> <!--<![endif]-->
<head>
    <meta charset="utf-8" />
    <title>Max's Muscle Up Challenge 2013</title>
    <meta name="description" content="" />
    <link rel="stylesheet" href="style.css" />
    <!--[if lt IE 9]>
    <script src="js/html5shiv.js"></script>
    <![endif]-->
<script type="text/javascript">
    setTimeout(loadGoogleAnalytics, 5000);
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-3115943-5']);
    _gaq.push(['_trackPageview']);

    function loadGoogleAnalytics()
    {
        var srcUrl = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';

        $.ajax(
        {
            url: srcUrl,
            cache: true,
            dataType: "script",
            success: function(data)
            {
                console.log('got the script');
            },
            error: function()
            {
                console.log('failed to get the script');
            },
            timeout: 5000
        });
    };
</script>
</head>
<body class="home">
    <div class="wrapper">
        <div class="container">
            <div class="clearfix">
                <header class="header">
                    <nav class="top-nav">
                        <ul class="clearfix">
                            <li><a href="index.php">Home</a></li>
                            <li><a href="videos.php">Videos</a></li>
                        </ul>
                    </nav><!-- /top-nav -->
                    <div class="logo">
                        <a href="index.php"><img src="img/logo.png" alt="" /></a>
                    </div><!-- /logo -->
                    <h1 class="banner">
                        Registrations open July 2013<br />
                        Challenge begins 29th July 2013
                    </h1><!-- /banner -->
                    <div class="before-after">
                        <ul class="clearfix">
                            <li>
                                <a href="img/01-large.jpg">
                                    <span class="plus"></span>
                                    <span class="image clearfix">
                                        <span class="before">
                                            <img src="img/01-before.jpg" alt="" />
                                            <span>BEFORE</span>
                                        </span>
                                        <span class="after">
                                            <img src="img/01-after.jpg" alt="" />
                                            <span>AFTER</span>
                                        </span>
                                    </span>
                                    <span class="title">
                                        <strong>GUILLAUME GEBERT</strong> - Winner (2012)
                                    </span>
                                </a>
                            </li>
                            <li>
                                <a href="img/02-large.jpg">
                                    <span class="plus"></span>
                                    <span class="image clearfix">
                                        <span class="before">
                                            <img src="img/02-before.jpg" alt="" />
                                            <span>BEFORE</span>
                                        </span>
                                        <span class="after">
                                            <img src="img/02-after.jpg" alt="" />
                                            <span>AFTER</span>
                                        </span>
                                    </span>
                                    <span class="title">
                                        <strong>ASHLEY MARSHALL</strong> - Top 10 (2012)
                                    </span>
                                </a>
                            </li>
                        </ul>
                    </div><!-- /before-after -->
                    <div class="view-other">
                        <a href="http://www.maxineschallenge.com.au" target="_blank">
                            <span>Click Here To View The Women’s Challenge</span>
                            <img src="img/maxines-logo.png" alt="" />
                        </a>
                    </div><!-- /view-other -->
                </header><!-- /header -->
                <div class="main">
                    <section class="register">
                        <header>
                            <hgroup>
                                <h1>ARE YOU UP FOR THE CHALLENGE?</h1>
                                <h2>REGISTER YOUR INTEREST HERE!</h2>
                            </hgroup>
                            <p>
                                Fill in your details here and we’ll send you<br />
                                information about when and how you can be<br />
                                part of the 2013 MAX’s Muscle Up Challenge!
                            </p>
                            <p>
                                Once you enter your details and press 'submit'<br />
                                you will receive a confirmation email.
                            </p>
                        </header>
                        <form method="post" action="complete.php" >
                        <input type="hidden" name="submitForm" value="1" />
                            <div class="field">
                                <div class="input-wrapper">
                                    <label class="label placeholder" for="name">Name</label><span class="required">*</span>
                                    <input class="input placeholder" type="text" name="name" id="name" required value="<?php echo htmlencode(@$_REQUEST['name']) ?>"/>
                                </div>
                            </div>
                            <div class="field">
                                <div class="input-wrapper">
                                    <label class="label placeholder" for="email">E-mail</label><span class="required">*</span>
                                    <input class="input placeholder" type="email" name="email" id="email" required value="<?php echo htmlencode(@$_REQUEST['email']) ?>"/>
                                </div>
                            </div>
                            <div class="field">
                                <div class="input-wrapper">
                                    <label class="label placeholder" for="postcode">Postcode</label><span class="required">*</span>
                                    <input class="input placeholder" type="number" name="postcode" id="postcode" required value="<?php echo htmlencode(@$_REQUEST['postcode']) ?>"/>
                                </div>
                            </div>
                            <div class="field">
                                <div class="select-wrapper">
                                    <select class="chzn-select" name="hear_about" id="hear-about" required>
                                        <option value="">How did you hear about the challenge?</option>
                                        <?php foreach (getListOptions("_nlb_subscribers", "hear_about") as $value => $label): ?>
                                        <option <?php selectedIf(@$_REQUEST['hear_about'],$value);?> value="<?php echo $value;?>" ><?php echo $label;?></option>
                                        <?php endforeach ?>
                                    </select>
                                </div>
                            </div>
                            <div class="field clearfix">
                                <button class="submit" type="submit" value="SUBMIT">SUBMIT</button>
                            </div>
                        </form>
                        <footer>
                            <strong>NOTE:</strong> By agreeing to register, you acknowledge we will send you information regarding the challenge. We take your privacy very seriously, and reassure you, your details will not in any way be distributed to any 3rd party suppliers
                        </footer>
                    </section>
                </div><!-- /main -->
            </div>
            <footer class="footer clearfix">
                <p class="fl">
                    &copy;Amino Active Pty Ltd 2013
                </p>
                <p class="fr">
                    <a class="privacy-open" href="privacy-policy.php">Privacy Policy</a>
                </p>
            </footer><!-- /footer -->
        </div>
    </div><!-- /wrapper -->
    
    <script src="js/jquery-1.7.2.min.js"></script>
    <script src="js/plugins.js"></script>
    <script src="js/script.js"></script>

</body>
</html>

Thanks



Craig

KC Media Solutions

www.kcmedia.biz