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

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

Postby crazydog » 11:09pm, Thu 06 Jul, 2006

How do I, instead of using a subscribe page, just put a form on my homepage with an Email Address field and a submit button, and have that sign people up?
crazydog
phpLister
 
Posts: 9
Joined: 11:07pm, Thu 06 Jul, 2006

Postby H2B2 » 12:28am, Fri 07 Jul, 2006

EDIT: It is recommended to first read this doc: Custom Subscribe Form
------

Place this code in a table cell and change it to match your setup and layout
Code: Select all
<!-- 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.yourdomain.com/lists/?p=subscribe&id=1" 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="signup" />
<input type="submit" name="subscribe" value="Subscribe" onClick="return checkform();">
</form>

<!-- newsletter subscribe ends here -->
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby crazydog » 8:53am, Sat 08 Jul, 2006

Alright. I changed it to fit what I need...
(Script is attached as txt file, because phpbb is editing my code =/)

(mywebsite.com isn't what I have in my code.)

All it does is brings me to http://mywebsite.com/newsletter/lists/?p=subscribe&id=1
Attachments
mycode.zip
(577 Bytes) Downloaded 1064 times
crazydog
phpLister
 
Posts: 9
Joined: 11:07pm, Thu 06 Jul, 2006

Postby H2B2 » 5:34am, Mon 10 Jul, 2006

Can't download your attachment. The download link seems to be empty. Try to post it here and be sure to check the box "Disable HTML in this post".
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby H2B2 » 12:58pm, Mon 10 Jul, 2006

OK, was able to download your code today. This is what you placed in your attachment:
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 method="post" action="http://mywebsite.com/newsletter/lists/?p=subscribe&id=1" name="subscribeform">
<input type="text" name="email" value = "Email Address" size="15"><br>
<script language="Javascript" type="text/javascript">addFieldToCheck("email","Email Address");</script>
<input type="hidden" name="list[1]" value="signup" />
<center><input type="submit" name="subscribe" value="Subscribe" onClick="return checkform();"></center>
</form>


And this is what you stated a being a problem:
(mywebsite.com isn't what I have in my code.)

All it does is brings me to http://mywebsite.com/newsletter/lists/?p=subscribe&id=1

But you don't mention what exactly the problem is, and I can't check for myself as the domain you entered in your code isn't yours. So please describe what the problem is: what were you expecting that didn't happen, and what happened that you didn't want to happen.
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby crazydog » 1:04pm, Mon 10 Jul, 2006

All that does is bring me to the default subscribe page.
I want the form to automatically submit it, not having to use the premade subscribe form.
crazydog
phpLister
 
Posts: 9
Joined: 11:07pm, Thu 06 Jul, 2006

Postby H2B2 » 1:30pm, Mon 10 Jul, 2006

Allright, could you check in the Admin backend what the list ID is, and post it here?
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby H2B2 » 1:45pm, Mon 10 Jul, 2006

And than try changing this part of the form code:
Code: Select all
<form method="post" action="http:/mywebsite.com/newsletter/lists/?p=subscribe&id=1" name="subscribeform">

to this:
Code: Select all
<form method="post" action="http://mywebsite.com/newsletter/lists/?p=subscribe" name="subscribeform">

and check you have this line of code:
Code: Select all
<input type="hidden" name="list[XXX]" value=signup>
where XXX is the list ID you have.


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
Last edited by H2B2 on 3:42pm, Wed 04 Oct, 2006, edited 2 times in total.
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby crazydog » 3:51pm, Mon 10 Jul, 2006

That worked. thanks
Last edited by crazydog on 4:11pm, Mon 10 Jul, 2006, edited 1 time in total.
crazydog
phpLister
 
Posts: 9
Joined: 11:07pm, Thu 06 Jul, 2006

Thanks

Postby Scrampy » 7:36am, Sun 06 Aug, 2006

I got it... followed instructions and got the subscribe listed on my own site (every page using template) ... very helpful, and much appreciated.

Great work H2B2
Scrampy
phpList newbie
 
Posts: 1
Joined: 6:22am, Sun 06 Aug, 2006

Postby thaivisitor » 5:40am, Tue 05 Sep, 2006

I must give my heartfelt gratitude to you H2B2!!!!

I have checked thru various posts to try to customize my subscription into my homepage without any success of doing it right but your instructions are just simply the best.

All I did was to copy your script(of course using my own domain and directory), paste it into the Code view of my website in MS Frontpage, edit it from Design view and I got my subscription working perfectly!!!! :lol:
It was done in 15 minutes (not counting the other hours that I took to look thru the forums).

Now I have to go about trying to figure out some other functions of phplist :cry:
viewtopic.php?t=2232&start=75

Anyway, once again, I thank you very much.

Cheers
ThaiVisitor
thaivisitor
phpLister
 
Posts: 14
Joined: 1:44am, Tue 05 Sep, 2006
Location: Thailand

Postby tomraffe » 12:11pm, Mon 18 Sep, 2006

When I fill in the form on my site I get redirected to http://www.example.co.uk/lists/?p=subscribe where I get the following message

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

Any ideas?
tomraffe
phpLister
 
Posts: 5
Joined: 12:10pm, Mon 18 Sep, 2006

Postby H2B2 » 12:27pm, Mon 18 Sep, 2006

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

Did you try disabling email confirmation in Admin >> subscribe pages >> check the radio button "Don't display email confirmation".
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby tomraffe » 12:40pm, Mon 18 Sep, 2006

Thats corrected that bit. It now says Name, is a required field, despite me completing it on the form. Obviously there is a problem with the field and the attribute?

My code is below. The Name attribute in my DB is simply Name.

Code: Select all
<!-- 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.e-discounts.co.uk/lists/?p=subscribe" name="subscribeform">
<input type="hidden" name="list[1]" value=signup>
Email:<input type="text" name="email" value = ""><br>
<script language="Javascript" type="text/javascript">addFieldToCheck("email","Email Address");</script>
Name: <input type="text" name="Name" value = "">
<script language="Javascript" type="text/javascript">addFieldToCheck("Name","Name");</script>
<input type="hidden" name="list[1]" value="signup" />
<input type="submit" name="subscribe" value="Subscribe" onClick="return checkform();">
</form>

<!-- newsletter subscribe ends here -->
Last edited by tomraffe on 1:03pm, Mon 18 Sep, 2006, edited 1 time in total.
tomraffe
phpLister
 
Posts: 5
Joined: 12:10pm, Mon 18 Sep, 2006

Postby H2B2 » 1:58pm, Mon 18 Sep, 2006

tomraffe wrote:It now says Name, is a required field, despite me completing it on the form. Obviously there is a problem with the field and the attribute?
Yes, that is exactly the problem. Instead of "Name" you should use something like "attributeX" for this form field, where X is the ID number of the attribute.

Assuming your attribute "Name" has ID number "1", try changing this:
Code: Select all
<input type="text" name="Name" value = "">
<script language="Javascript" type="text/javascript">addFieldToCheck("Name","Name");</script>

to this:
Code: Select all
<input type="text" name="attribute1" value = "" ><script language="JavaScript" type="text/javascript">addFieldToCheck("attribute1","Name");</script>


You can check the ID number of the attribute you created in :
- Admin >> subscribe pages >> Edit
or in:
- Admin >> Manage users >> User attributes
Find the attribute "Name" and you should see the ID number on the top left side.

BTW, your form code only need one instance of this input tag:
Code: Select all
<input type="hidden" name="list[1]" value="signup" />
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Next

Return to Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 0 guests