[how to] put a subscribe form on one of my website pages

Solutions for other phpList version 2 users
Forum rules
Please do not ask questions here, this is for Solutions you have discovered or come across.

Postby mpettitt » 9:21am, Wed 11 Apr, 2007

I'm trying to put a basic subscribe form on a Joomla based site (not interested in integrating the mailing list and Joomla user lists, as the site doesn't allow Joomla user registrations), but am having a problem with custom attributes.
I've copied the form code, modified the action, and got rid of the listname input, and the form submits successfully (the email address is added to the database, and a verification email is sent), but all custom attributes are lost. If I use the PHPlist generated subscribe page, with exactly the same code (copy pasted across), the attributes work as expected.

Any ideas what is going on?

Working, PHPlist generated code:
Code: Select all
<form method=post name="subscribeform"><table border=0>
  <tr><td><div class="required">Email</div></td>
  <td class="attributeinput"><input type=text name=email value="" size="40">
  <script language="Javascript" type="text/javascript">addFieldToCheck("email","Email");</script></td></tr>
  <tr><td><div class="required">Confirm email</div></td>

  <td class="attributeinput"><input type=text name=emailconfirm value="" size="40">
  <script language="Javascript" type="text/javascript">addFieldToCheck("emailconfirm","Confirm email");</script></td></tr><tr><td colspan=2>
        <span class="attributename">Preferred format for emails:</span><br/>
        <span class="attributeinput"><input type=radio name="htmlemail" value="0"  /></span>
        <span class="attributename">Text</span>
        <span class="attributeinput"><input type=radio name="htmlemail" value="1" checked /></span>
        <span class="attributename">HTML</span></td></tr>

<tr><td><div class="required">Name</div></td><td class="attributeinput">
            <input type=text name="attribute2"  class="attributeinput" size="40" value=""><script language="Javascript" type="text/javascript">addFieldToCheck("attribute2","Name");</script></td></tr>

<tr><td><div class="required">Company Name</div></td><td class="attributeinput">
            <input type=text name="attribute3"  class="attributeinput" size="40" value=""><script language="Javascript" type="text/javascript">addFieldToCheck("attribute3","Company Name");</script></td></tr>
</table><input type="hidden" name="list[2]" value="signup"><input type="hidden" name="listname[2]" value="Builder and Engineer Newsletter"/><div style="display:none"><input type="text" name="VerificationCodeX" value="" size="20"></div><p><input type=submit name="subscribe" value="Subscribe to the Selected Newsletters" onClick="return checkform();"></p>
    </form>


Non-working code, modified as suggested in this thread:
Code: Select all
<form method="post" name="subscribeform" action="http://www.excelpublishing.co.uk/lists/?p=subscribe">
<table border=0>
  <tr><td><div class="required">Email</div></td>
  <td class="attributeinput"><input type=text name=email value="" size="40">
  <script language="Javascript" type="text/javascript">addFieldToCheck("email","Email");</script></td></tr>
  <tr><td><div class="required">Confirm email</div></td>

  <td class="attributeinput"><input type=text name=emailconfirm value="" size="40">
  <script language="Javascript" type="text/javascript">addFieldToCheck("emailconfirm","Confirm email");</script></td></tr><tr><td colspan=2>
        <span class="attributename">Preferred format for emails:</span><br/>
        <span class="attributeinput"><input type=radio name="htmlemail" value="0"  /></span>
        <span class="attributename">Text</span>
        <span class="attributeinput"><input type=radio name="htmlemail" value="1" checked /></span>
        <span class="attributename">HTML</span></td></tr>

<tr><td><div class="required">Name</div></td><td class="attributeinput">
            <input type=text name="attribute2"  class="attributeinput" size="40" value=""><script language="Javascript" type="text/javascript">addFieldToCheck("attribute2","Name");</script></td></tr>

<tr><td><div class="required">Company Name</div></td><td class="attributeinput">
            <input type=text name="attribute3"  class="attributeinput" size="40" value=""><script language="Javascript" type="text/javascript">addFieldToCheck("attribute3","Company Name");</script></td></tr>
</table><input type="hidden" name="list[2]" value="signup"><div style="display:none"><input type="text" name="VerificationCodeX" value="" size="20"></div><p><input type=submit name="subscribe" value="Subscribe to the Selected Newsletters" onClick="return checkform();"></p>
    </form>


(I've not included the script parts that appear before each form - identical on both, and seem to work as expected, since it objects if required fields aren't filled in)
mpettitt
phpList newbie
 
Posts: 3
Joined: 1:42pm, Tue 10 Apr, 2007

Postby H2B2 » 6:15pm, Fri 13 Apr, 2007

Did you check this?
Note: The phplist generated form code is HTML 4.01 Transitional. If you use another "doc type" in your custom page -like XHTML 1.0 Strict for instance- review the code to make sure it is compliant with your doc type.
Source: http://docs.phplist.com/CustomSubscribeForm

To meet your doc type's requirements, you may need to review all your input tags' double quotes and trailing slashes.
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Heeelllpp....

Postby mag72 » 7:38am, Sat 14 Apr, 2007

OK...I've spent about twenty hours or so getting this script to work on my Wordpress page, with no luck. I need help.

This is my 'newsletter signup' page: http://michiganjapan.com/join/

I took the advice earlier in this thread and copied to code from my signup page and posted it into my wordpress page. OK, no problems there, looks like I want it to (except for the fields not showing in Firefox...they're completely white...hmmm).

Here's the code I copied into the page:

Code: Select all
<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;
}

function compareEmail()
{
  return (document.subscribeform.elements["email"].value == document.subscribeform.elements["emailconfirm"].value);
}

</script>
<form method="post" action="http://www.michiganjapan.com/wordpress/lists/?p=subscribe" name="subscribeform" target="_self">
<table border=0>
  <tr><td><div class="required">E-Mail</div></td>
  <td class="attributeinput"><input type=text name=email value="" size="40">
  <script language="Javascript" type="text/javascript">addFieldToCheck("email","E-Mail");</script></td></tr><input type=hidden name="htmlemail" value="1">

<tr><td><div class="required">E-Mail</div></td><td class="attributeinput">
            <input type=text name="attribute1"  class="attributeinput" size="40" value=""><script language="Javascript" type="text/javascript">addFieldToCheck("attribute1","E-Mail");</script></td></tr>

<tr><td><div class="required">Name</div></td><td class="attributeinput">
            <input type=text name="attribute2"  class="attributeinput" size="40" value=""><script language="Javascript" type="text/javascript">addFieldToCheck("attribute2","Name");</script></td></tr>

<tr><td><div class="attributename">Company or Organization</div></td><td class="attributeinput">
            <input type=text name="attribute3"  class="attributeinput" size="40" value=""></td></tr>

<tr><td><div class="attributename">Address (1)</div></td><td class="attributeinput">
            <input type=text name="attribute4"  class="attributeinput" size="40" value=""></td></tr>

<tr><td><div class="attributename">Address (2)</div></td><td class="attributeinput">
            <input type=text name="attribute5"  class="attributeinput" size="40" value=""></td></tr>

<tr><td><div class="attributename">Address (3)</div></td><td class="attributeinput">
            <input type=text name="attribute6"  class="attributeinput" size="40" value=""></td></tr>

<tr><td colspan=2>
            <div class="attributename">Message</div></td></tr><tr><td class="attributeinput" colspan=2>
            <textarea name="attribute7" rows="10"  class="attributeinput" cols="40" wrap="virtual"></textarea></td></tr>
</table><input type="hidden" name="list[1]" value="signup"><input type="hidden" name="listname[1]" value="MJPA Main"/><p><input type=submit name="subscribe" value="Join The MJPA" onClick="return checkform();"></p>
    </form><br/><br/>
    <p><a href="http://michiganjapan.com/wordpress/lists/?p=unsubscribe&id=3">Unsubscribe</a></p>


Now, when I fill out the form, it just takes me to: http://www.michiganjapan.com/wordpress/ ... be...which is completely blank. If I reload the page, it shows the signup fields, but completely separate from my blog (no formatting). It doesn't add the user at all...it doesn't seem to be making any contact with the PHPList script and/or database.

*** PHPList Version: 2.10.4
*** Wordpress: 2.1.3 w/Orange Crush Theme
*** I only have one list, and it's numbered '1'.
*** (...if there is only one visible list, should it be hidden in the page and automatically subscribe users who sign up (0/1))
...is set to 'true'.
*** PHPList seems to be installed OK--I can add/edit users in the admin panel as well as send out e-mails OK.

Any help is GREATLY appreciated.
mag72
phpLister
 
Posts: 9
Joined: 7:29am, Sat 14 Apr, 2007

Postby H2B2 » 9:41am, Sat 14 Apr, 2007

Try removing this input tag:
Code: Select all
<input type="hidden" name="listname[1]" value="MJPA Main"/>


mag72 wrote:except for the fields not showing in Firefox...they're completely white...
The doc type of your page is XHTML 1.0 Strict.
So you need to review your form code (e.g. double quotes, slashes) as mentioned in the documentation:
Note: The phplist generated form code is HTML 4.01 Transitional. If you use another "doc type" in your custom page -like XHTML 1.0 Strict for instance- review the code to make sure it is compliant with your doc type.
Source: http://docs.phplist.com/CustomSubscribeForm
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

OK~

Postby mag72 » 6:26pm, Sat 14 Apr, 2007

OK, I removed the:

Code: Select all
<input type="hidden" name="listname[1]" value="MJPA Main"/>
tag....but still get the same exact problem. It just takes me to a blank page and doesn't add anyone to the PHPList.

As far as the doctype, I checked it all for backwards compatibility--nothing changed. Then I changed the doctype to 4.01 trans--nothing changed.

Still stuck.
Last edited by mag72 on 6:42pm, Sat 14 Apr, 2007, edited 1 time in total.
mag72
phpLister
 
Posts: 9
Joined: 7:29am, Sat 14 Apr, 2007

Postby H2B2 » 6:33pm, Sat 14 Apr, 2007

Removing the input tag is to avoid redirection to the general listing of lists.

Making your form code compliant with your doctype is a prerequisite for the form working at all,
in particular when using "XHTML 1.0 Strict".
I suggest you use a W3C validator to review the html code of this page.
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

It's changed

Postby mag72 » 6:43pm, Sat 14 Apr, 2007

Changed the page-type to HTML 4.01 trans (edited the code n the global header file in Wordpress)...still having the same problem.

EDIT: Was going to go through the entire page and make sure evrything validates for HTML 4.01...but it's impossible. The entire thing (Wordpress) is built around XML, including the main field hat makes everything work (xmlrpc.php).
mag72
phpLister
 
Posts: 9
Joined: 7:29am, Sat 14 Apr, 2007

Postby H2B2 » 7:07pm, Sat 14 Apr, 2007

You can keep the "XHTML 1.0 Strict" doctype. Just use a validator to review the code, e.g. http://validator.w3.org/
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Still trying...

Postby mag72 » 8:07pm, Sat 14 Apr, 2007

OK, so I used the W3 validator, went through my code....but for some reason it reads the Javascript part wrong(?) and brings up a bunch of validation errors.

Example:
Code: Select all
Error  Line 103 column 33: character ";" not allowed in attribute specification list.

  for (i=0;i<fieldstocheck.length;i++) {


or this, in the forms section:

Code: Select all
Error  Line 122 column 92: there is no attribute "name".

...m/wordpress/lists/?p=subscribe" name="subscribeform">


Is there even anything I can do about things like that?
mag72
phpLister
 
Posts: 9
Joined: 7:29am, Sat 14 Apr, 2007

Postby H2B2 » 8:26pm, Sat 14 Apr, 2007

I'm afraid my experience and knowledge of XHTML coding conventions is too limited to be of help here.

Still, found this forum user that has a custom form placed on a WordPress page: http://tallentedchef.com/
Ref: http://forums.phplist.com/viewtopic.php?p=29210#29210

The above user mentions that he's using "the Funky Penguin plugin to integrate PHPlist into my Wordpress installation".
You might look into it.

Anyway, if you would take a look at the source code of http://tallentedchef.com/ you'd see that the page's doctype
is "XHTML 1.0 Transitional", which is more forgiving then the "strict" variant. You might see if that works for you.
Additionally you could compare his code to yours and see you can solve this issue.
Last edited by H2B2 on 8:31pm, Sat 14 Apr, 2007, edited 2 times in total.
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Alright

Postby mag72 » 8:30pm, Sat 14 Apr, 2007

Thanks, I'll look into it.

The reason I'm trying to do it by hand is that every plugin (including the one you mentioned) I've tried using is outdated (either outdated for Wordpress or PHPList) and doesn't work properly.
mag72
phpLister
 
Posts: 9
Joined: 7:29am, Sat 14 Apr, 2007

No luck....

Postby mag72 » 9:30pm, Sat 14 Apr, 2007

Even with the page validated I get the same problem...
when the button is pushed it just takes me to a blank page, that's it.

EDIT: I've found that this isn't a problem with doctype or anything like that, because if I create a brand new subscription page in the admin panel and open it up separately, I still get the same problem--blank page. I'm going to ask about this problem in a separate thread.
mag72
phpLister
 
Posts: 9
Joined: 7:29am, Sat 14 Apr, 2007

Postby H2B2 » 10:32pm, Sat 14 Apr, 2007

You will get the same result when using the default phplist generated subscribe page: http://www.michiganjapan.com/wordpress/ ... cribe&id=1

Apparently the blank page issue is not your custom form, but something else. Did you activate the list (newsletter)? Try creating a new list and make sure you click on "save and activate"

I also noticed that your phplist generated subscribe form contains a custom attribute for the email field (i.e. attribute1). Phplist already has a field called "email". So remove/de-activate attribute1 from your subscribe page, both custom and phplist generated.

Continued in this thread: http://forums.phplist.com/viewtopic.php?t=9331
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Re: Still trying...

Postby beanstalk » 9:06pm, Sun 15 Apr, 2007

try the other method in my post on page 3 of this thread. you can use a file with the following to get your root path:
Code: Select all
phpinfo();
beanstalk
PL Nut
 
Posts: 23
Joined: 3:19pm, Fri 20 Oct, 2006
Location: Ohio

Postby mpettitt » 9:21am, Mon 16 Apr, 2007

H2B2 wrote:Did you check this?
Note: The phplist generated form code is HTML 4.01 Transitional. If you use another "doc type" in your custom page -like XHTML 1.0 Strict for instance- review the code to make sure it is compliant with your doc type.

To meet your doc type's requirements, you may need to review all your input tags' double quotes and trailing slashes.


Yes. No difference, hence trying the output exactly as PHPlist generated it.

It submits, adds the basic user details, but not the attributes. It does this every time I attempt to submit through the custom form, while the form directly generated by PHPlist works as expected.
mpettitt
phpList newbie
 
Posts: 3
Joined: 1:42pm, Tue 10 Apr, 2007

PreviousNext

Return to Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest