[how to] implement my subscribe page with my website

Once you've installed phpList Version 2... ask questions here!
Forum rules
Please help the volunteers to help you by supplying the version of phpList you are using, browser & version and if possible, a link to your phpList installation. This is for Version 2 of phpList (the orange one).

[how to] implement my subscribe page with my website

Postby filipoka » 1:25pm, Thu 19 Apr, 2012

Hi guys,

I am not really good with PHP and stuff, but I am trying to integrate my phplist subscribe page with my website but I don''t have much of a success. What I want to do is just put a form on my homepage with an Email Address field and a submit button, and have that sign people up. Unfortunately I when you fill in the form on my site I get redirected to http://www.example.com/newsletter/?p=subscribe where I get the following message:

"The following required values are missing: Email Addresses you entered do not match"

And I need to fill the e-mail address again in order to receive a confirmation letter and I can not solve this step.

I tried to follow all the instructions: clicked "Don't display email confirmation" button, also, check this setting on the configuration page (admin >> configure):
- if there is only one visible list, should it be hidden in the page and automatically subscribe users who sign up (0/1)
true

My code is as follow:
Code: Select all
</div>
<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.mydomain.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>
Name: <input type="text" name="attribute2" value = "">
<script language="Javascript" type="text/javascript">addFieldToCheck("attribute2","Name");</script>
<input type="hidden" name="list[1]" value="test" />
<input type="submit" name="subscribe" value="Subscribe" onClick="return checkform();">
</form>

<!-- newsletter subscribe ends here -->
                                                       </div>
                                                       <div class="clear">&nbsp;</div>
                                               </div>
                                       </div> <!-- end content_container -->
                               </div> <!-- end site_container -->
                       </div> <!-- end site_container_aligner -->   
       </body></html>


I am sure it is something not that complex, but because of lack of understanding I can not solve it. I would be very thankful if somebody can help me with this.

Thanks
filipoka
phpLister
 
Posts: 14
Joined: 10:33am, Thu 19 Apr, 2012

Re: [how to] implement my subscribe page with my website

Postby duncanc » 9:13am, Fri 20 Apr, 2012

Here's the code that works for my site, using AJAX. You should be able to tailor it to your site.

Code: Select all
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  <form action="" method="" id="newsletter">
      <input type="hidden" name="VerificationCodeX" value="" />
      <input type="hidden" name="list[2]" value="signup">
      <input type="hidden" name="listname[2]" value="ECS e-newsletter - public"/>
      <input type="hidden" name="subscribe" value='subscribe'/>
      <label for="email">E-mail</label> <input type="text" size="20" value="" name="email" id="email" />
      <label for="name">Name</label> <input type="text" size="20" value="" name="attribute1" id="Name" />
      <p><a class='button' href="javascript; return false;"
      onclick="$.ajax({type: 'POST', data: $('#newsletter').serialize(), url: 'http://www.xxxxxx.org/lists/?p=subscribe&id=2', success: function(msg){ alert('Thank you for your registration. Please check your email to confirm.'); $('#Name').val(''); $('#email').val(''); }, failure: function(msg){ alert('Sorry, we were unable to process your subscription.'); }}); return false;"
      >Subscribe</a></p>
  </form>

On lines 4 and 5, the '2' needs to be the id of the list to which the user is subscribing

On line 10, the 2 refers to the id of the subscription page, not the list id.
The subscribe page is defined to default to HTML format emails, not display email confirmation, and offer only one list. It also has a user attribute called 'Name'.

On the configure page, the setting "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.

If you search the forum for 'ajax' then you'll find the topic from which I copied this.
duncanc
Moderator
 
Posts: 2440
Joined: 6:34am, Sat 08 May, 2010
Location: London

Re: [how to] implement my subscribe page with my website

Postby filipoka » 3:37pm, Wed 02 May, 2012

Thank you, it worked perfectly after I paste your script :)

Now I have a problem with changing the Text in the Welcome page after you press the confirmation link. I managed to change the header and the footer as I want to, but still can not find the function where the text can be changed.

Any suggestions would be helpfull thanks a lot.

Cheers
filipoka
phpLister
 
Posts: 14
Joined: 10:33am, Thu 19 Apr, 2012

Re: [how to] implement my subscribe page with my website

Postby SkyTower123 » 4:09am, Wed 11 Dec, 2013

Please help.
I'm trying to this code and it doesn't add any emaill to the list.

I just have this plain code on my page
http://www.invokegames.com/email__name.htm

Code: Select all
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>E-mail&nbsp; Name</title>
</head>

<body>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
      <form action="" method="" id="newsletter">
          <input type="hidden" name="VerificationCodeX" value="" />
          <input type="hidden" name="list[2]" value="signup">
          <input type="hidden" name="listname[2]" value="newsletter"/>
          <input type="hidden" name="subscribe" value='subscribe'/>
          <label for="email">E-mail</label> <input type="text" size="20" value="" name="email" id="email" />
          <label for="name">Name</label> <input type="text" size="20" value="" name="attribute1" id="Name" />
          <p><a class='button' href="javascript; return false;"
          onclick="$.ajax({type: 'POST', data: $('#newsletter').serialize(), url: 'http://www.invokegames.com/lists/?p=subscribe&id=1', success: function(msg){ alert('Thank you for your registration. Please check your email to confirm.'); $('#Name').val(''); $('#email').val(''); }, failure: function(msg){ alert('Sorry, we were unable to process your subscription.'); }}); return false;"
          >Subscribe</a></p>
      </form>

</body>

</html>


I have newsletter subscribe list as order number 2.
On the configure page, the setting "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.

I tried changing ?p=subscribe&id=2 to 1 and 2 and list[2] with listname[2] to 1 and 2 and vise versa to no avail.

The default subscribtion page lets me to add emails though.
I'm using version 3.0.5
What is going on? Spent 2 days on this, tried other codes from this board, it just wont add new emails.

Any suggestions?
SkyTower123
phpList newbie
 
Posts: 1
Joined: 3:54am, Wed 11 Dec, 2013


Return to Question & Problems - after installing

Who is online

Users browsing this forum: No registered users and 4 guests