Page 1 of 2

Fully integrated into site, with small sign up form starter

PostPosted: 12:27pm, Thu 23 Aug, 2007
by clubwager
I have fully integrated phplist 2.10.4 into my site.

I have a small form for email submission on every page. When it is submitted it goes to the full form page for more selections. Look at

The full form is at

***SPAM*** Alerts use the rss function.

I incorporated captcha using SOLMETRA FormValidator from
Comments are welcome.

PostPosted: 1:46pm, Thu 23 Aug, 2007
by Dragonrider
Hi Dave,

Whilst the subject matter does not appeal to me personally, gotta say That is a VERY good customizing of phpList!!

Way to go!

I do like the Subscribe on every page option, and the Captcha thing is very neat! Would you care to share how you did it? Please? (both)

PostPosted: 11:30pm, Thu 23 Aug, 2007
by clubwager
Thank you for your kind words.

The small sign up form on every page was done by simply taking the html form generated by phplist in a subscribe page, and modifying it by moving most of the javascript to an external file and stripping away all of the html. Then, I styled the resulting bare form to a size and look that fit in with the rest of the site.

There is much more detail on doing this at this thread:

Here is the code for the entire form:
Code: Select all
<form id='newsletter' style="margin-right:0px;margin-left:0px;margin-bottom:5px;margin-top:0px;padding:0px;width:180px" action="/lists/?p=subscribe" method="post" name="subscribeform">
<label for="Email" style="padding-top:3px;font-size:10px;width:33px;float:left;clear:left;color:navy;font-weight:bold;margin-right:0px;margin-bottom:2px">Email</label><input name="email" type="text" style="font-size:10px;width:127px;height:13px;color:navy;background:#F5FFFA;border:1px solid #8FB98E;margin-bottom:2px;margin-left:3px" id="Email" value="" size="20" maxlength="100" />
<script language="Javascript" type="text/javascript">addFieldToCheck("email","Email");</script>
  <input name="attribute4" type="hidden" value="" /> 
  <input type="hidden" name="list[2]" value="signup" />
  <input type="hidden" name="listname[2]" value="Club Wager Newsletter" />
  <input type="hidden" name="htmlemail" value="1" />
  <input name="subscribe" type="submit" style="height:22px;width:52px;text-align:center;font-size:10px;padding:0px;margin-right:0px;margin-left:0px;margin-bottom:0px;margin-top:0px;float:left;clear:left;" value="Continue" onclick="return checkform();" /> </form>

I set this up to make the full form open when an email is submitted. I want the subscriber to have a chance to subscribe to the rss feeds (***SPAM*** alerts) and I wanted to use captcha to try to reduce spambot sign ups. In my installation, "attribute4" is the name field - which I set to be required. By using type="hidden" and value="" for that attribute, phplist will force open the main form with an error message that the name is needed. The other variables (email, list, etc.) are all passed to the main form, so the subscriber does not need to re-enter that info.

Everyone is welcome to try this form out on my site. So long as you do not click the confirmation link in the email the system sends, you will not get any of our email newsletter or ***SPAM*** alerts and your email address will be removed after 72 hours. Even if you choose to confirm to see the thank you page etc., you can easily unsubscribe after you are done testing it.

As to how I got captcha working, it is more complex. I have noticed some other posts looking for this, so I will try to put together some detailed instructions and post a new topic with it as soon as I can.

Thanks again for your feedback.

PostPosted: 3:02pm, Fri 07 Sep, 2007
by kuber
Very good. This is exactly what I have been meaning to do. Thanks for sharing it with us.

PostPosted: 11:54pm, Sat 13 Oct, 2007
by clubwager
Here is my quick and dirty solution to integrate SOLMETRA FormValidator captcha into phplist version 2.10.4 (see it working at

SOLMETRA FormValidator is free GPL when integrated into GPL-licensed software. Start by downloading and installing SOLMETRA FormValidator Essentially, all you need to do is extract the downloaded archive to a separate directory on your hard disk (I called it "captcha"), and upload it to your server, and make sure the directory is writeable (usually set permissions to be writeable by owner and readable and executable by all; i.e., CHMOD 755).

Then, assuming you installed SOLMETRA FormValidator in a directory called "captcha" and phplist is installed in a directory called "lists", make these changes to phplist files:

In /lists/admin/subscribelib2.php at about line 7 right after
Code: Select all
$randval = mt_rand();
add this code:
Code: Select all
 // begin captcha code
$obj = new SPAF_FormValidator();
if (isset($_POST['Verification'])) {
  if ($obj->validRequest($_POST['Verification'])) {
    // destroy successful code
  else {
    exit('<p>Verification Code was entered incorrectly.</p> <p><ol><li>Please use the &quot;back&quot; button on your browser to return to the form, and</li><li>Fill out the form and re-submit it with the verification characters correctly entered.</li></ol>If you keep getting this error, please contact us for assistance.</p>');
// end captcha code

In /lists/index.php at about line 450 right after
Code: Select all
if (empty($data['button'])) {
    $data['button'] = $GLOBALS['strSubmit'];

add this code:
Code: Select all
 // begin captcha code
  $html .= '<table><tr><td><img src="../captcha/img.php?&amp;&lt;?php echo time(); ?&gt;" alt="Enter these 6 characters in the box below."></td></tr><tr><td><div class="required">Enter the Verification Code from the above box:</div></td><td class="attributeinput"> <input name="Verification" class="attributeinput" size="6" maxlength="6" value="" id="verification_code" type="text"><script language="Javascript" type="text/javascript">addFieldToCheck("Verification","verification_code");</script></td></tr></table>'; 
// end captcha code 

Add this near the top of /lists/config/config.php:
Code: Select all
# to use captcha on subscription forms set this to true; to not use it set this to false

Unfortunately, using captcha does not make phplist invulnerable to spambots. The problem is that although captcha assures there is a real human when a visitor submits the form from a website, it does not have any effect if the form is bypassed by making a direct submission/request to the server. See the discussion at I tried to solve this by making certain form fields (that a spambot might not recognize), required. Seems to have worked so far.

Thanks, and some additions

PostPosted: 12:25am, Thu 18 Oct, 2007
by admash
I am brand new to PHPList, and after beating my head against the wall trying to get CAPTCHA to work, this thread gave me the tools to get going. A couple of additions:

In order to display the image using SOLMETRA, you have to be sure and add the full image tag to the code in index.php. For instance, if you have PHPlist inside the 'lists' dir, and 'captcha' located inside the 'lists' dir, the code from the example might be:

Code: Select all
// begin captcha code
  $html .= "<table><tr><td><img></td></tr><tr><td><div>Enter the Verification Code from the above box:</div></td><td> <input><script>addFieldToCheck(\"Verification\",\"verification_code\");</script></td></tr></table>";
// end captcha code

Another thing that I had to do since 'captcha' was located inside my 'lists' directory, was to modify the .htaccess file to allow the img.php. Just open .htaccess and find:


and change to


If these edits seem strange or out of 'best practices', please correct me. This is simply how this is working for me now.

EDIT: I see what happened now, the forum edits the script when we post. To get the script to work, you have to add the 'src' and path to img.php inside the <img> tag (spaced out for the forum):


EDIT 2: - well, the forum keeps editing out the code, sorry! the .htaccess edit is simply adding img.php to the allowed pages, and the other is just fixing the source of the html image tag. Sorry about the edits!

Re: Thanks, and some additions

PostPosted: 1:31am, Thu 18 Oct, 2007
by H2B2
admash wrote:EDIT: I see what happened now, the forum edits the script when we post. To get the script to work, you have to add
the 'src' and path to img.php inside the <img> tag (spaced out for the forum):

When posting HTML code on the forum, you should make sure you click on "Disable HTML in this post" on the left of your
editing window. Otherwise HTML tags will be truncated. Try editing your post, paste the code again and select "Disable HTML in this post".

PostPosted: 3:24pm, Sat 27 Oct, 2007
by helloukw

This works for latest version also?

I can't get it work , the image doesn't show up.

Please help!


PostPosted: 3:45pm, Sat 27 Oct, 2007
by clubwager
Check the path to where you have SPAF_FormValidator.class.php. Also, make sure the permissions allow you to write.

If you need help, please tell me what version of phplist you are using and where you installed it and give me the url to where you are trying the page where the form is located so I can look at it.

PostPosted: 4:57pm, Sat 27 Oct, 2007
by helloukw
I'm using PhpList 2.10.5

Here is the URL : visual85 dot com /lists/

I installed "Captcha" in visual85 dot com/captcha/

Thank you for help!

PS: Sry i can't post links yet, i don`t have enough posts.

PostPosted: 5:15pm, Sat 27 Oct, 2007
by clubwager
In the posts above there appears to be a problem if captcha is under the lists folder. I do not know what causes it but you might try simply moving the captcha folder to the main directory. Make sure it has correct permissions.

You could also try just making sure you use the correct full absolute path to the captcha folder such as
Code: Select all

PostPosted: 5:18pm, Sat 27 Oct, 2007
by helloukw
I managed to make the image appear.. it put the full path to img.

Another problems appears tho.. it validates no matter if i put the right answer or not.

Any ideas why?

PostPosted: 8:28pm, Sat 27 Oct, 2007
by clubwager
This forum deletes some html code unless the "Disable HTML in this post" box is checked. I failed to do that in the original Sun Oct 14, 2007 6:54 am post above so it omitted some essential code that is needed in the index.php file. I have now edited that prior post to correct it.

Thank you for catching this and bringing it to my attention. Let me know if you have any other problems with it.

PostPosted: 9:17pm, Sat 27 Oct, 2007
by helloukw
Works like a charm now!

Thank you so much!

PostPosted: 4:18pm, Wed 07 Nov, 2007
by rmacian
In case that the image does not appear and if you try to see the image you recieve an error like thtat the createimagefrompng does not exist you have to install the package php5-gd and restart apache.

Now I can see the image but if I try to subcribe to a list I can t do it. After introducing the right code I am redirected to the subsribe page again with a different code.

Any idea?