[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 sarelvdm » 2:06pm, Tue 10 Oct, 2006

Hi

Im getting a funny error.

This is what happens.
1. I enter my information into my custom subscription page. and click on submit.
2. A second subcription page (it is the standard php list subscription page) pops up. It contains all the information that I have entered in my custom page.
3. I will only receive my welkom email after I click the button on the second subscription page.
Please take a look at my code.

Thanks

** my code **
Code: Select all
This is a scrip validator program ---- it works
-------------------------------------------------
<script language="JavaScript" src="../script_tmt_validator.js" type="text/javascript"></script>

<form method=post action="http://website/phplist/?p=subscribe" name="subscribeform" tmt:validate="true" >
 
 
  <p class="normal"><br />
    <span class="heading">To receive information on upcoming events. Please enter</span></p>
  <p class="heading style4 style28">* Required fields </p>
  <table width="600" border="0" align="center" cellpadding="2" cellspacing="2">

<!-- E-mail -->   
   <tr valign="top" height="20"><td width="290" align="right" class="Normalbold">
      <b> E-mail: </b> </td>
   <td width="296"><input type="text" name="email" size="40" value="" tmt:required="true" tmt:errorclass="invalid" tmt:message="Please insert a valid email" tmt:pattern="email"/>  <span class="style26">*</span></td>
    </tr>

<!-- E-mail confirmation-->     
   <tr valign="top" height="20">
     <td width="290" align="right" class="Normalbold">
      <p><b> E-mail Confirmation: </b> </p>
      <p><br />
        </p></td>
     <td><input type="text" name="emailconfirm" size="40" value="" tmt:required="true" tmt:errorclass="invalid" tmt:message="Please insert a valid email" tmt:pattern="email"/>  <span class="style26">*</span></td>
    </tr>


<!-- Email html   -->     
   <tr valign="top" height="20">
     <td width="290" align="right" class="Normalbold">
      <p><b> I perfer to receive emails<br />
        in </b> HTML format </p>
      </td>
     <td><select name="htmlemail" >
          <option value="0" selected="selected">Receive plain e-mail</option>
          <option value="0">Receive plain e-mail</option>
          <option value="1">Receive HTML format e-mail</option>
        </select>      </td>
    </tr>

<!-- Name  --> 
   <tr valign="top" height="20"><td width="290" align="right" class="Normalbold">
      <b> Name : </b> </td>
   <td><input type="text" name="attribute1" size="30"  tmt:required="true" tmt:message="Please insert your Name"/>
     <span class="style26">*</span></td>
    </tr>

<!-- Surname -->     
   <tr valign="top" height="20"><td width="290" align="right" class="Normalbold">
      <b> Surname : </b> </td>
   <td><input type="text" name="attribute2" size="30"  value="" tmt:required="true" tmt:message="Please insert your Surname"/>
     <span class="style26">*</span></td>
    </tr>

<!-- Gender -->     
   <tr valign="top" height="20"><td width="290" align="right" class="Normalbold">
      <b> Gender : </b> </td>
   <td><select name="attribute3" id="f_gender">
          <option value="M" selected="selected">Male</option>
          <option value="M">Male</option>
          <option value="F">Female</option>
        </select>      </td>
    </tr>

  </table>
 
 
    <div align="center"><br />
      <input type="hidden" name="list[1]" value="signup">
      <input type="hidden" name="listname[1]" value="this is my test list"/>
      <p>
      <input type=submit name="subscribe" value="Subscribe to the Selected Newsletters" onClick="return checkform();">

       <input type="reset" name="resetForm" value="Clear Form" />
    </div>
</form>
sarelvdm
PL Nut
 
Posts: 15
Joined: 5:49pm, Sun 17 Sep, 2006

Postby H2B2 » 2:28pm, Tue 10 Oct, 2006

sarelvdm wrote:1. I enter my information into my custom subscription page. and click on submit.

2. A second subcription page (it is the standard php list subscription page) pops up. It contains all the information that I have entered in my custom page.

Code: Select all
<input type="hidden" name="list[1]" value="signup">
<input type="hidden" name="listname[1]" value="this is my test list"/>

Try these steps:
1. Check this setting on the configuration page (admin >> configure):
Code: Select all
- if there is only one visible list, should it be hidden in the page and automatically subscribe users who sign up (0/1)
true

2. Remove this input tag:
Code: Select all
<input type="hidden" name="listname[1]" value="this is my test list"/>

3. Remove this input tag IF you offer more than one list (newsletter) in your form:
Code: Select all
<input type="hidden" name="list[1]" value="signup">
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby sarelvdm » 8:38pm, Tue 10 Oct, 2006

Hi.

I have followed your steps, no luck.

a) I only got one active subscription page at this stage but want to add 2 more subscription pages.
b) Can you please explain your steps. I dont understand.

thanks

Supervan
sarelvdm
PL Nut
 
Posts: 15
Joined: 5:49pm, Sun 17 Sep, 2006

Postby H2B2 » 1:25am, Wed 11 Oct, 2006

This is your form posted earlier, but reduced to essentials:

<form method=post action="http://website/phplist/?p=subscribe" name="subscribeform">

<input type="text" name="email" size="40" value="" />
<input type="text" name="emailconfirm" size="40" value="" />

<select name="htmlemail">
<option value="0" selected="selected">Receive plain e-mail</option>
<option value="0">Receive plain e-mail</option>
<option value="1">Receive HTML format e-mail</option>
</select>


<input type="text" name="attribute1" size="30" />
<input type="text" name="attribute2" size="30" value="" />

<select name="attribute3" id="f_gender">
<option value="M" selected="selected">Male</option>
<option value="M">Male</option>
<option value="F">Female</option>
</select>


<input type="hidden" name="list[1]" value="signup">
<input type="hidden" name="listname[1]" value="this is my test list"/>

<input type=submit name="subscribe" value="Subscribe" onClick="return checkform();">
<input type="reset" name="resetForm" value="Clear Form" />
</form>

I think one or both of your selection boxes may be causing problems. Try removing all lines in red from your form. See if that works. If so, you can start building and testing from there.

When offering two or more lists (newsletters) in one form, you will have to remove the above green input field. This will be replaced by these input fields:
<input type="checkbox" name="list[1]" value=signup />
<input type="checkbox" name="list[2]" value=signup />
<input type="checkbox" name="list[3]" value=signup />
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby H2B2 » 4:40pm, Tue 17 Oct, 2006

I have recently created a documentation page on this topic:
How to place a custom subscribe form on an existing webpage.

Please consult this page as a starting point on this subject. Reading this, and related threads on the forum is of course highly recommended if you encounter problems with setting up your custom subscribe form.
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

another method

Postby beanstalk » 6:13pm, Fri 20 Oct, 2006

i came up with another method for this. make sure that your page will be parsed by php - give it a *.php extension for example. then put the following code in where you want the subscription form to be. be sure to enclose it in php tags and change it to fit your file structure and names.

Code: Select all
$custompage = 'http://www.yoursite.com/custompage.php';
$_ENV["CONFIG"] = 'yourrootpath/lists/config/config.php';
require_once('yourrootpath/lists/index.php');


unfortunately, you need to change one of the phplist files as well. if we can convince the developers into putting a variable there in the future, we will not have to. change the following in /lists/index.php:

Code: Select all
printf('<p><a href="./?p=subscribe&id=%d">%s</a></p>',$row["id"],$row["title"]);
     }
  } else {
    printf('<p><a href="./?p=subscribe">%s</a></p>',$strSubscribeTitle);
  }

  printf('<p><a href="./?p=unsubscribe">%s</a></p>',$strUnsubscribeTitle);


to:

Code: Select all
printf('<p><a href="'.$custompage.'?p=subscribe&id=%d">%s</a></p>',$row["id"],$row["title"]);
     }
  } else {
    printf('<p><a href="'.$custompage.'?p=subscribe">%s</a></p>',$strSubscribeTitle);
  }

  printf('<p><a href="'.$custompage.'?p=unsubscribe">%s</a></p>',$strUnsubscribeTitle);



in fact, i think i just improved on my method. you may put $_SERVER['HTTP_REFERER'] in place of the $custompage variable in the index.php file. in your custom file, you can delete the $custompage variable definition.
Last edited by beanstalk on 7:26pm, Tue 21 Nov, 2006, edited 4 times in total.
beanstalk
PL Nut
 
Posts: 23
Joined: 3:19pm, Fri 20 Oct, 2006
Location: Ohio

change this mod to be html option default

Postby casanova_jaime » 4:10am, Tue 07 Nov, 2006

Great mod! got it working but the subscription is set default to receive text mails and not html mails, how can I change that?

I set to "html only" option in my subscribe page configuration but still marks text mails for my subscribers.

And other question: what's the name of the file that displays de "Thank you stuff"? I want to change that so my subscribers can have the links back to my site.

Thanks! Really useful mod!
casanova_jaime
PL Nut
 
Posts: 19
Joined: 3:58am, Tue 07 Nov, 2006

Postby beanstalk » 4:58am, Tue 07 Nov, 2006

what mod method are you using? mine or the original? don't know about the original, but mine should work just the same as it would when you are using phpList stock. so setting the html option in your spage should do the trick.

also, the 'thank you' page info is stored in the db and the page is generated by the 'lists\index.php' file. with my mod, all you need to do is change your thank you text on the spage. i couldn't get a 'thank you' page from the original method.
beanstalk
PL Nut
 
Posts: 23
Joined: 3:19pm, Fri 20 Oct, 2006
Location: Ohio

Postby casanova_jaime » 4:26pm, Tue 07 Nov, 2006

Thanks beanstalk, but which one is your method? I'm using H2B2's method, made some changes but still makes all my subscribers receive text mesages and not html mesages. My code looks like this:

<!-- 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.mysitename.com/newsletter/?p=subscribe" name="subscribeform">
Email:<input type="text" name="email" value = ""><br>
<script language="Javascript" type="text/javascript">addFieldToCheck("email","Email Address");</script>
<input type="hidden" name="list[2]" value="signup" />
<input type="submit" name="subscribe" value="Subscribe" onClick="return checkform();">
</form>

<!-- newsletter subscribe ends here -->



I don't know if I have to add something to this so it subscribes for html mails as default.

Edit: Maybe I could add the radio buttons for html and text so my subscribers choose, but I don't know how to do that, any suggestions?
casanova_jaime
PL Nut
 
Posts: 19
Joined: 3:58am, Tue 07 Nov, 2006

Postby H2B2 » 10:01pm, Tue 07 Nov, 2006

casanova_jaime wrote:I don't know if I have to add something to this so it subscribes for html mails as default.
You could try adding this line in your form code:
Code: Select all
<input type=hidden name="htmlemail" value="1" checked>
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby casanova_jaime » 2:14am, Wed 08 Nov, 2006

That was really easy!! just changed
<input type=hidden name="htmlemail" value="1" checked>


to
<input type="hidden" name="htmlemail" value="1" checked>


and works perfeclty now!

Congratulations and thanks for the great mod!
casanova_jaime
PL Nut
 
Posts: 19
Joined: 3:58am, Tue 07 Nov, 2006

Postby H2B2 » 2:32am, Wed 08 Nov, 2006

Thanks for the feedback! :D
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Just found my problem

Postby ShavenYak » 4:08pm, Tue 21 Nov, 2006

I've been reading this forum trying to figure out why my custom subscribe form wasn't working... it was just taking me to my subscribe page.

I went exactly by the instructions in the docs, and my form looked just like the form on the subscribe page. Turns out that was the problem...

You see, the PHPList subscribe pages have an HTML 4.01 Transitional doctype. My site is XHTML 1.0 Strict. The difference is that under the Strict doctype, the value of an attribute must be in quotes. So:
Code: Select all
<form method=post ... >

doesn't work - it has to be
Code: Select all
<form method="post" ... >


At least in IE6, and probably other browsers, the lack of quotes caused it to ignore the POST method, and I'm assuming it did a GET instead, thus the subscribe page displayed.

Hope this helps someone else avoid banging their head into the wall like I did. Now if you'll excuse me, I need an aspirin.
ShavenYak
phpList newbie
 
Posts: 1
Joined: 3:44pm, Tue 21 Nov, 2006

Re: Just found my problem

Postby H2B2 » 6:14pm, Tue 21 Nov, 2006

ShavenYak wrote:You see, the PHPList subscribe pages have an HTML 4.01 Transitional doctype. My site is XHTML 1.0 Strict. The difference is that under the Strict doctype, the value of an attribute must be in quotes.

Good point. I'll include this in the corresponding documentation page: http://docs.phplist.com/CustomSubscribeForm
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby beanstalk » 6:21pm, Tue 21 Nov, 2006

i was really hoping someone would try my method. it seemed much easier to me, with less customization of the code involved. you can still use phplist for all your subscribe page changes and such. plus all the confirmation pages work.

not looking for personal glory. just want comments and enough people using it that we could ask the developers to change some code such that we would not have to modify any of the phplist files and could more easily upgrade.

oh well...
beanstalk
PL Nut
 
Posts: 23
Joined: 3:19pm, Fri 20 Oct, 2006
Location: Ohio

PreviousNext

Return to Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 2 guests