[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.

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

Postby YogaWithBryce » 11:57am, Wed 17 Nov, 2010

Hi there, I have been having troubles getting this to work as well. When I´m hitting the submit button on my website subscribe, I keep getting redirected to the default phplist subscription page with the fields filled in the data I entered already. When I hit the "Subscribe" button on the default page it then process correctly. I am sure it something simple I have messed up, but for the life of me have not been able to locate it. I have tried pretty much everything listed in this thread.

My website
http://www.yogawithbryce.com.au

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;
}
</script>
    <form id="subscribeform" name="subscribeform" method="post" action="http://www.yogawithbryce.com.au/phplist/?p=subscribe" >
      <input name="attribute3" value="enter your name" type="text" id="namefield" />
        <script language="Javascript" type="text/javascript">addFieldToCheck("attribute3","Name");</script>
      <input name="email" value="enter your email" type="text" id="email" />
        <script language="Javascript" type="text/javascript">addFieldToCheck("email","Email Address");</script>
      <input type="hidden" name="list[2]" value="signup" />
      <input name="subscribe" src="images/subscribe.jpg" id="submit" type="image" onclick="return checkform();">
   </form>
YogaWithBryce
phpList newbie
 
Posts: 1
Joined: 11:47am, Wed 17 Nov, 2010

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

Postby honzavag » 9:54am, Tue 08 Feb, 2011

Hello, this code works well. But I would like to add another input fields to send another post data. When I add another field to form like this:
<div class="email_phplist">Your Friend's Email:</div>
<div><input class="phplist" name="email_1" size="15" type="text" /></div>

the page is redirected to home page.

All code I have in form:

<form action="http://www.xxx.com/lists/?p=subscribe&id=4" method="post">
<div class="email_phplist">Your Email:</div>
<div><input class="phplist" name="email" size="15" type="text" /></div>
<script type="text/javascript">// <![CDATA[
addFieldToCheck("email","Email Address");
// ]]></script>
<br />
<div class="email_phplist">Your Friend's Email:</div>
<div><input class="phplist" name="email_1" size="15" type="text" /></div>

<input name="list[2]" type="hidden" value="signup" /> <input class="submit_phplist" onclick="return checkform();" name="subscribe" type="submit" value="Get For Free Immediately" />
</form>

Does anybody have any idea how to do it? The added fields should only send POST data to index.php. There is added mail function to send email.
Jan
honzavag
phpLister
 
Posts: 8
Joined: 6:45pm, Sun 09 Jan, 2011

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

Postby H2B2 » 11:22am, Wed 02 Mar, 2011

YogaWithBryce wrote:I keep getting redirected to the default phplist subscription page with the fields filled in the data I entered already. When I hit the "Subscribe" button on the default page it then process correctly.
{...]
Code: Select all
  <input name="subscribe" src="images/subscribe.jpg" id="submit" type="image" onclick="return checkform();">

You are using a clickeable image to submit the form. A similar issue was described by TVLe:
TVLe wrote:The code seems to work from the first page. The only problem is with IE. For some reason when submitting the form in IE it goes to a secondary page that requires you to click a submit button again. In firefox it automatically submits from the first page.

TVLe wrote:I must have skipped over this part. I added that hidden element and it works like a charm. Weird, though, that firefox wasnt picky about it and IE is.

* If you want to use an image instead of the standard submit button, you must add the following hidden field tag to your form:
Code: Select all
<input type="hidden" name="subscribe" value="yes">

ref: memberlist.php?mode=viewprofile&u=53225
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

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

Postby checkmate » 9:51am, Wed 27 Apr, 2011

Hi there

I am trying to get this working by the document on the support website. but when i do search i cant find the form action field. i some how have a token option?
Code: Select all
<form method=post name="subscribeform"><input type="hidden" name="formtoken" value="070a662866821c852fb0276ebdc317b7" /><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 your email address</div></td>
  <td class="attributeinput"><input type=text name=emailconfirm value="" size="40">
  <script language="Javascript" type="text/javascript">addFieldToCheck("emailconfirm","Confirm your email address");</script></td></tr><input type=hidden name="htmlemail" value="1">
 
<tr><td><div class="required">First Name</div></td><td class="attributeinput">
            <input type=text name="attribute1"  class="attributeinput" size="40" value=""><script language="Javascript" type="text/javascript">addFieldToCheck("attribute1","First Name");</script></td></tr>
 
<tr><td><div class="required">Surname</div></td><td class="attributeinput">
            <input type=text name="attribute2"  class="attributeinput" size="40" value=""><script language="Javascript" type="text/javascript">addFieldToCheck("attribute2","Surname");</script></td></tr>
 
<tr><td><div class="required">Gaam</div></td><td class="attributeinput">
            <input type=text name="attribute3"  class="attributeinput" size="40" value=""><script language="Javascript" type="text/javascript">addFieldToCheck("attribute3","Gaam");</script></td></tr>
 
<tr><td><div class="required">Location</div></td><td class="attributeinput"><!--0--><select name="attribute4" class="attributeinput"><option value="2" >East London<option value="3" >Other UK<option value="4" >India<option value="5" >Australia<option value="6" >Africa<option value="7" >USA<option value="8" >Europe<option value="9" >Other</select></td></tr>
</table><input type="hidden" name="list[2]" value="signup"><input type="hidden" name="listname[2]" value="Newsletter"/><div style="display:none"><input type="text" name="VerificationCodeX" value="" size="20"></div><p><input type=submit name="subscribe" value="Subscribe" onClick="return checkform();"></p>
    </form>
checkmate
phpList newbie
 
Posts: 4
Joined: 5:04pm, Tue 22 Dec, 2009

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

Postby codediddler » 5:37pm, Fri 29 Apr, 2011

PHPHosted

I cannot avoid going to my subscribe page. I have faithfully tweaked all the form information I have, but no matter what browser I'm in, I end up at the subscriber page. The email confirmation gets sent, though.

My guess is that my problem is the way the hosted subscriber page is configured.
codediddler
phpList newbie
 
Posts: 1
Joined: 5:32pm, Fri 29 Apr, 2011

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

Postby H2B2 » 1:41am, Wed 11 May, 2011

codediddler wrote:PHPHosted

If you mean "phpList Hosted", I'm not sure. Haven't had the time to check that.

You could post this question in the PL Hosted section: viewforum.php?f=30 and on the contact form of your Hosted account. Keep us updated (in the PL Hosted section) . 8)
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

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

Postby borsodas » 4:58am, Sun 17 Jul, 2011

try using ajax



<script type="text/javascript">
$(document).ready ( function () {
$('#go').click ( function () {
$.ajax ( {
type: 'POST',
data: $('#newsletter').serialize (),
url: $('#newsletter').attr ('action'),
success: function () {
$('#thankYou').show (
1000,
function () {
setTimeout ( function() { $('#thankYou').hide(1000); }, 3000);
}
);
}
} );
return false;
} );
} )

</script>
borsodas
phpLister
 
Posts: 8
Joined: 3:39pm, Sat 23 Apr, 2011

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

Postby erindepew » 3:00am, Tue 19 Jul, 2011

I'm having a very silly issue... I can get the subscribe form working fine through phplist, and then as soon as I copy all of the code into the div on my own website, using their instructions here http://docs.phplist.com/CustomSubscribeForm, it doesn't work. It shows up fine but people aren't able to subscribe through my page which is www.marbleheadcliffs.com/subscribe.html but they are able to subscribe through http://www.marbleheadcliffs.com/mailinglist/.
Is there something I need to turn on or off to get this to work?

Thanks
erindepew
phpList newbie
 
Posts: 1
Joined: 2:40am, Tue 19 Jul, 2011

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

Postby Zesty » 5:19am, Sun 21 Aug, 2011

THX H2B2 !! :D :D
Zesty
phpList newbie
 
Posts: 3
Joined: 4:56am, Sun 21 Aug, 2011

Image as submit button: FIXED

Postby Spyce » 8:57pm, Fri 21 Oct, 2011

So I have my form all set up... I really like how it looks.

I have the subscribe form up on my website (http://www.vanilla-chai.nu) and I'm trying to add dummy users. But when I hit the 'Subscribe' button, you just get taken to the default subscribe page asking to enter your email.... I don't want this. I want the user to be brought to the default 'thank you' page. I had this working earlier, but I don't know what's wrong with it now.

EDIT: Upon further investigation, I've come to realize that when I use the standard submit button, everything works perfectly. But if I change the submit button to an image, the form doesn't submit like I want it to. Does anybody know why this is?

FIXED: So I figured I would post this here in case it might help somebody else out there.

I've been searching the net for hours on how to fix this issue, all to no avail. That is, until I came upon a very simple workaround using CSS. To be able to use an image AND have the form submit properly I added the following code to my input:

Code: Select all
style="background: url(http://www.vanilla-chai.nu/img/subscribe.png); width: 205px; height: 75px; border: 0px;"


I left the input type as type="submit" and passed along a blank value (value=""), and it works perfectly. The only caveat I could find was, when somebody hovers their mouse over the submit image, and even clicks, the cursor remains an arrow. I tried adding cursor: hand; to my inline style, but it didn't. I'm sue there is a way to do that- but I don't feel like fussing with that right now. I'm just glad I have it working the way I want. I don't think the style of the cursor is really a huge deal anyway.

This is what my form looks like:

Code: Select all
<script language="Javascript" type="text/javascript">
   function checkform() {
     for (i=0;i<fieldstocheck.length;i++) {
       if (eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].type") == "checkbox") {
         if (document.subscribeform.elements[fieldstocheck[i]].checked) {
         } else {
           alert("Please enter your "+fieldnames[i]);
           eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].focus()");
           return false;
         }
       }
       else {
         if (eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].value") == "") {
           alert("Please enter your "+fieldnames[i]);
           eval("document.subscribeform.elements['"+fieldstocheck[i]+"'].focus()");
           return false;
         }
       }
     }
     for (i=0;i<groupstocheck.length;i++) {
       if (!checkGroup(groupstocheck[i],groupnames[i])) {
         return false;
       }
     }
    
     return true;
   }

   var fieldstocheck = new Array();
   var fieldnames = new Array();
   function addFieldToCheck(value,name) {
     fieldstocheck[fieldstocheck.length] = value;
     fieldnames[fieldnames.length] = name;
   }

   var groupstocheck = new Array();
   var groupnames = new Array();
   function addGroupToCheck(value,name) {
     groupstocheck[groupstocheck.length] = value;
     groupnames[groupnames.length] = name;
   }

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

   function checkGroup(name,value) {
     option = -1;
     for (i=0;i<document.subscribeform.elements[name].length;i++) {
       if (document.subscribeform.elements[name][i].checked) {
         option = i;
       }
   }
       if (option == -1) {
          alert ("Please enter your "+value);
           return false;
       }
       return true;
   }
</script>

<form action="http://www.vanilla-chai.nu/lists/?p=subscribe" method="post" name="subscribeform">
   <input type="hidden" name="formtoken" value="c8f9f2b0f152b05322267bff0ba0971d" />
      <table border=0 cellpadding="0" cellspacing="0">
         <tr>
            <td class="attributeinput">
               <center>
                  <span class="required">
                  Name:&nbsp;&nbsp;<input type="text" name="name" value="" size="21">
                  <br />
                  Email:&nbsp;&nbsp;<input type=text name=email value="" size="22">
                  </span>
               </center>
               <script language="Javascript" type="text/javascript">addFieldToCheck("name","Name,"email","Email");</script>
            </td>
         </tr>
         <tr>
            <td colspan="2">
               <input type="image" src="http://www.vanilla-chai.nu/img/subscribe.png" name="subscribe" value="" onClick="return checkform();">
               <input type="hidden" name="htmlemail" value="1">
               <input type="hidden" name="list[1]" value="signup">
               <input type="hidden" name="listname[1]" value="test"/>
               <div style="display:none"><input type="text" name="VerificationCodeX" value="" size="10"></div>
               </p>
            </td>
         </tr>
      </table>
</form>
Spyce
phpList newbie
 
Posts: 3
Joined: 7:39pm, Fri 21 Oct, 2011

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

Postby filipoka » 1:22pm, 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] put a subscribe form on one of my website pages

Postby vpbx » 1:02am, Thu 03 May, 2012

Hi fellow php listers.

I have the subscribe feature working well on my CSS formatted site. The issue i have is that after the submission is preformed i am defaulted to the thank you page in the default phplist template.

I have a default page of my own but how do i change the code to call that page and not the default phplist one..

Any help would be great.
vpbx
phpList newbie
 
Posts: 1
Joined: 12:53am, Thu 03 May, 2012

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

Postby RBlack912 » 2:33pm, Fri 04 May, 2012

OK, I'm following along here and I've done all this but when I click submit it still takes me to the signup form page... How do I make it bypass the signup page and automatically sign them up and start sending out the confirmation emails... Why would I have them submit two forms?

http://www.ryanslinks.com
RBlack912
phpLister
 
Posts: 10
Joined: 8:33pm, Tue 17 Apr, 2012

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

Postby boriss » 12:26pm, Wed 01 Aug, 2012

Thank you very much, H2B2! Worked at first try! :wink:
boriss
phpList newbie
 
Posts: 3
Joined: 11:11pm, Tue 31 Jul, 2012

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

Postby zotek » 8:11am, Mon 11 Mar, 2013

please help ive been working on this for 19 hours and still cant get it to work..everytime i click submit i get redirected to phplist default form..please help here is my code..thank you

Code: Select all
<div id="wb_sandboxForm1" style="position:absolute;left:340px;top:145px;width:742px;height:415px;z-index:2;">
<form name="subscribeform" method="post" action="http://mywebsite/lists/?p=subscribe" target="_self" id="sandboxForm1">
<input type="hidden" name="list[3]" value="signup">
<input type="text" id="sandboxEditbox2" style="position:absolute;left:83px;top:44px;width:341px;height:100px;line-height:100px;z-index:0;" name="email" value="" placeholder="Email address">
<input type="submit" id="sandboxButton1" name="" value="Submit" style="position:absolute;left:442px;top:192px;width:165px;height:86px;z-index:1;">
</form>
</div>
zotek
PL Nut
 
Posts: 17
Joined: 7:30am, Mon 11 Mar, 2013

PreviousNext

Return to Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 2 guests