larger smaller normal text version of this page
Phplist Documentation » Configuration functions » Configuring subscribe pages » Editing or creating a subscribe page »

Custom Subscribe Form


This page describes how to create a customized subscribe form, which you can place on an existing page of your site. This method should work both with simple and complex subscribe forms.


How to place a custom subscribe form on an existing webpage


This procedure will let PHPlist do the 'dirty work' of generating the form code. Then you only need to copy the form code, customize it a little bit, and place it on your webpage.
  • First, create a subscribe page with all the attributes you need. Select which attributes are "required," and set the order of listing. Don't forget to click on "Save and activate."
  • Then, on the configuration page, make sure this setting is set to "true" (or 1):
if there is only one visible list, should it be hidden in the page and automatically subscribe users who sign up (0/1)
true

  • Run some tests to make sure that your standard phplist subscribe page is working as you'd want it to work. Only proceed with the next step, if you really are satisfied with the way the subscribe page works.
  • Now you need to copy the phplist generated HTML form code to a text editor. You can do this as follows:
    • Load the subscribe page you just created in your web browser, i.e. just point your browser to your subscribe page.
    • Display the source code for that page (right click on the page and select 'View source' in IE, or 'View page source' in Firefox).
    • Copy the form code (including the javascript that checks user input), and paste this in a simple text editor, like Windows Notepad.
  • Then, you need to customize the form code as described here.
Change this:
<form method="post" name="subscribeform">

  • to this, if you have just one single subscribe page:
    <form method="post" action="http:/mysite.com/lists/?p=subscribe" name="subscribeform">
  • or to this, if you have several subscribe pages, where &id=x is the ID number of a particular subscribe page:
    <form method="post" action="http:/mysite.com/lists/?p=subscribe&id=1" name="subscribeform">
If you offer just one single list (e.g. one newsletter) in your subscribe form, check you have this hidden input tag in your form (where x is the ID number of the list):
<input type="hidden" name="list[x]" value="signup">

However, if you offer more than one list in your subscribe form, make sure you remove the above input tag.
  • Now you are ready to place the customized form in a table cell or anywhere you want on an existing webpage. Further customization can be done in your favorite HTML editor, if you prefer.

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.


Some tips & tricks

  • If a user forgets to select a list to subscribe to and clicks on the Submit button, he will be redirected to the default phplist subscribe page. One way to avoid this from happening is to make the list pre-selected by adding "checked" to the corresponding input tag, e.g.:
<input type="checkbox" name="list[1]" value="signup" checked />
  • If you don't want to display the default 'thank you' page, and instead want to open a pop-up window, you could use this code:
<form method="post" action="http://www.mysite.com/lists/?p=subscribe" name="signup" target="windowName" onsubmit="window.open('', this.target,
'dialog,modal,scrollbars=no,resizable=no,width=550,height=300,left=0,top=0');"
>
  • If you want to use an image instead of the standard submit button, you must add the following hidden field tag to your form:
<input type="hidden" name="subscribe" value="yes">


For more info, please consult the de facto support thread on the forum: http://forums.phplist.com/viewtopic.php?t=5712


Related pages

CategoryDocumentation
Page was generated in 0.1524 seconds