Embed a Custom Subscribe Form

Version 3 Solutions you have discovered or come across should go here. Questions should go in the other three Version 3 forums, thank you.
Forum rules
Please do not ask questions here, this is for Version 3 Solutions you have discovered or come across.

Embed a Custom Subscribe Form

Postby Dragonrider » 3:29pm, Sun 22 Sep, 2013

Every now and then someone asks how to embed a Custom Subscribe Form (CSF) in a website.

The instructions on the original doc's page are still as valid for Version 3 as they were when originally written.

One thing to bear in mind when setting the CSF up is that it needs to have the same attributes as your actual subscribe form does. IE: If you ask on the Regular Subscribe Form (RFS) for a confirmation email address and/or name, then your CSF should also ask for the same info.

It is important to Read This Page as it will give you a broad outline about how a CSF works. Don't worry though, I'll try to include the code here that you need.


The code on the very first page of this topic, which is repeated below still works.

Code: Select all
<!-- newsletter subscribe below here -->

<script language="Javascript" type="text/javascript">
var fieldstocheck = new Array();
fieldnames = new Array();
function checkform() {
for (i=0;i<fieldstocheck.length;i++) {
if (eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].value") == "") {
alert("Please enter your "+fieldnames[i]);
eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].focus()");
return false;
}
}
return true;
}
function addFieldToCheck(value,name) {
fieldstocheck[fieldstocheck.length] = value;
fieldnames[fieldnames.length] = name;
}
</script>

<form method="post" action="http://www.yourdomain.com/lists/?p=subscribe&id=1" name="subscribeform">
Email:<input type="text" name="email" value = ""><br>
<script language="Javascript" type="text/javascript">addFieldToCheck("email","Email Address");</script>
Name: <input type="text" name="attribute2" value = "">
<script language="Javascript" type="text/javascript">addFieldToCheck("attribute2","Name");</script>
<input type="hidden" name="list[1]" value="signup" />
<input type="submit" name="subscribe" value="Subscribe" onClick="return checkform();">
</form>

<!-- newsletter subscribe ends here -->



If you wish to try this demo out, you'll even get a confirmation email (that you can ignore as the list is only a demo). My Embed Demo
This uses the code above, adjusted for my test phpList 3 install and just has a single email and name entry form.

You may also would like to try this version which asks for confirmation of email as well as your name AND opens the Thank you page in a popup window too. Again, this uses the above code, plus the adjustments from the docs page.
My sites:- http://wharfedalefestival.co.uk, http://ilkleygardeners.org.uk, http://emergencyaid.net, http://dragonrider.co.uk
Latest phpList version is now 3.0.12 (3 February 2015) and requires a minimum of MySQL 5.0 and PHP 5.3.x
Dragonrider
Moderator
 
Posts: 3460
Joined: 6:58am, Sun 02 Jul, 2006
Location: Ilkley, West Yorkshire, United Kingdom

Re: Embed a Custom Subscribe Form

Postby cadsite » 7:31pm, Fri 17 Jan, 2014

I used a very old script, ccmail, I now try to upgrade to phplist, but the custom subscription form won't work.

The page:
http://www.cadsite.be/diverse/nieuwsbrief.php

The code:
Code: Select all
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>juliens cadsite - Nieuwsbrief</title>
<meta name="Title" content="juliens cadsite - Nieuwsbrief">
<meta name="Author" content="julien">
<meta name="Subject" content="autocad">
<meta name="Description" content="Het nieuwsbrief archief van cadsite.be">
<meta name="Keywords" content="autocad blocks lisp tutorial block forum Autocad gratis cursus lessen">
<meta name="Language" content="Nederlands">
<meta name="Revisit-After" content="30 Days">
<meta name="Robots" content="All">
<link rel="SHORTCUT ICON" href="http://www.cadsite.be/favicon.ico">
<script type="text/javascript" language="JavaScript" src="http://www.cadsite.be/favoriet.js">
</script>
<link rel="stylesheet" type="text/css" href="http://www.cadsite.be/julien.css">
</head>
<body>
 <div id="venster">

<?php echo file_get_contents("../menu.txt"); ?>
<h1>Nieuwsbrief</h1>

Wens je een nieuwsbrief te ontvangen van cadsite.be met cad-nieuws en nieuws over cadsite.be?<br />
<font color="#FF0000">Het inschrijven lukt nog niet, ik ben er mee bezig.</font><br>
<!-- newsletter subscribe below here -->

<script language="Javascript" type="text/javascript">
var fieldstocheck = new Array();
fieldnames = new Array();
function checkform() {
for (i=0;i<fieldstocheck.length;i++) {
if (eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].value") == "") {
alert("Please enter your "+fieldnames[i]);
eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].focus()");
return false;
}
}
return true;
}
function addFieldToCheck(value,name) {
fieldstocheck[fieldstocheck.length] = value;
fieldnames[fieldnames.length] = name;
}
</script>

<form method="post" action="http://www.cadsite.be/nieuwsbrief/lists/?p=subscribe&id=1" name="subscribeform">
Email:<input type="text" name="email" value = ""><br>
<script language="Javascript" type="text/javascript">addFieldToCheck("email","Email Address");</script>
Name: <input type="text" name="attribute2" value = "">
<script language="Javascript" type="text/javascript">addFieldToCheck("attribute2","Name");</script>
<input type="hidden" name="list[1]" value="signup" />
<input type="submit" name="subscribe" value="Subscribe" onClick="return checkform();">
</form>

<!-- newsletter subscribe ends here -->

Er zal maximaal 1 nieuwsbrief per maand verzonden worden.<br />
In elke e-mail zal een link staan vanwaar je je kan uitschrijven.<br>
<br>
<b>Wedstrijd</b><br />
Momenteel is er geen wedstrijd.<br />
<br />
<a href="wedstrijdreglement.php">wedstrijd reglement</a>
<br>
<br>
<h2>Zelf een prijs schenken?</h2>
Wens je zelf een prijs te schenken via de maandelijkse nieuwsbrief? Dat kan, neem dat even <a href="http://www.cadsite.be/contact/contact.php">contact</a> op om verder af te spreken.<br>
<br>
<hr>
<h2>Archief</h2><br />
<table>
<tr>
<th width="150px" align="left">2012</th>
<th width="150px" align="left">2011</th>
<th width="150px" align="left">2010</th>
<th width="150px" align="left">2009</th>
<th width="150px" align="left">2008</th>
<th width="150px" align="left">2007</th>
</tr>
<tr>
<td valign="top">
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2012-07_archief.php">Juli 2012</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2012-05_archief.php">Mei 2012</a><br />
</td>
<td valign="top">
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2011-01_archief.php">Januari 2011</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2011-02_archief.php">Februari 2011</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2011-03_archief.php">Maart 2011</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2011-05_archief.php">Mei 2011</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2011-06_archief.php">Juni 2011</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2011-07_archief.php">Juli 2011</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2011-08_archief.php">Augustus 2011</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2011-09_archief.php">September 2011</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2011-10_archief.php">Oktober 2011</a><br />
</td>
<td valign="top">
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2010-01_archief.php">Januari 2010</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2010-02_archief.php">Februari 2010</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2010-03_archief.php">Maart 2010</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2010-04_archief.php">April 2010</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2010-05_archief.php">Mei 2010</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2010-06_archief.php">Juni 2010</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2010-07-08_archief.php">Zomer 2010</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2010-09_archief.php">September 2010</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2010-10_archief.php">Oktober 2010</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2010-11_archief.php">November 2010</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2010-12_archief.php">December 2010</a><br />
</td>
<td valign="top">
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2009-01_archief.php">Januari 2009</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2009-02_archief.php">Februari 2009</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2009-03_archief.php">Maart 2009</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2009-04_archief.php">April 2009</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2009-05_archief.php">Mei 2009</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2009-06_archief.php">Juni 2009</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2009-11_archief.php">November 2009</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2009-12_archief.php">December 2009</a><br />
</td>
<td valign="top">
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2008-01_archief.php">Januari 2008</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2008-02_archief.php">Februari 2008</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2008-03_archief.php">Maart 2008</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2008-04_archief.php">April 2008</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2008-05_archief.php">Mei 2008</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2008-06_archief.php">Juni 2008</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2008-07-08_archief.php">Zomer 2008</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2008-09_archief.php">September 2008</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2008-10_archief.php">Oktober 2008</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2008-11_archief.php">November 2008</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2008-12_archief.php">December 2008</a><br />
</td>
<td valign="top">
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2007-11_archief.php">November 2007</a><br />
<a href="http://www.cadsite.be/diverse/nieuwsarchief/2007-12_archief.php">December 2007</a><br />
</td>
</tr>
</table>

<?php include('../voet.html'); ?>
</div>
</body>
</html>

It looks good, but after submitting I receive a 404.

Somebody any idea what I do wrong?

Thanks in advance!
cadsite
phpList newbie
 
Posts: 1
Joined: 7:27pm, Fri 17 Jan, 2014


Return to Answers, HowTos, Tips and Tricks

Who is online

Users browsing this forum: No registered users and 2 guests