Forum Moderators: coopster

Message Too Old, No Replies

phpList: Subscribers are not getting sent to 'thank you' page.

         

Spyce

10:43 pm on Oct 21, 2011 (gmt 0)

10+ Year Member



I'm under a bit of a time crunch with this, and I've been struggling with it for *hours*. I've asked on the phpList forums, I've even asked on Yahoo Answers, and I swear there's nobody on the internet today, because I have received no answers. Hopefully somebody here can help me.

If you visit my website (linked under my profile) you'll notice there's a form in the sidebar to subscribe to my email list. This is powered by phpList which I have installed on my server.

When a user enters their details and hits "subscribe"- they are taken to the default subscribe page. When you subscribe from there everything is golden. But this is not what I want. I want a user to sign up on my home page, and then when they hit submit, they are taken to the default 'thank you' page. No custom thank you pages or anything (this seems to be the only thing I can find when I do a google search)... just the default 'thank you' page.

EDIT: upon further investigation, I notice that if I use a standard submit button, everything works perfectly. But if I use a custom submit button- such as an image- the form doesn't send properly. any clue why this is?

this is the code for my form:


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


I am about ready to pull my hair out over this. Is there anybody out there that knows about phpList and can help me?

Thank you in advance.

rocknbil

4:45 pm on Oct 24, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



But if I use a custom submit button- such as an image- the form doesn't send properly.


<input type="image" src="http://example.com/img/subscribe.png" name="subscribe" value="" onClick="return checkform();">

#1. Pretty sure it's because your Javascript is returning true and type=image is not a submit button. For this to work you should have

function checkform() {
// I usually have a var
// called "msg", if it's not empty echo an
// alert, otherwise submit the form
var msg='';
var form = document.forms['subscribeform'];
// do your validations. Concatenate to
// msg if found. if (some error) { msg += 'error msg'; }
if (msg == '') { form.submit(); }
else { alert(msg); }
return false;
}

Better yet, move the handler to the form tag, this allows you to pass the form as an object and allows the user to press enter to submit.

<form action="http:///example.com/lists/?p=subscribe" method="post" name="subscribeform" onsubmit="return checkform();";>
.....
<input type="image" src="http://example.com/img/subscribe.png" name="subscribe" value="">

function checkform(theform) {
var msg='';
// do your validations. Concatenate to
// msg if found. if (some error) { msg += 'error msg'; }
if (msg == '') { theform.submit(); }
else { alert(msg); }
return false;
}

Note it returns false in any case, allowing Javascript to manage the submit. You could do your true/false return as well in the second case.

function checkform(theform) {
var msg='';
// do your validations. Concatenate to
// msg if found. if (some error) { msg += 'error msg'; }
if (msg == '') { return true; }
else { alert(msg); return false; }
}

Even better YET, don't use input type=image, use a normal submit and style it accordingly. This allows you to create mouseover states for the button, which you can't do with input type="image" (without Javascript:)

<input type="submit" name="subscribe" id="submitButton" value="Submit">


#submitButton {
display: block;
width: 200px;
height: 50px;
outline: none;
border:none;
text-indent: -50000px;
background:url(/img/subscribe.png) top left no-repeat;
}
/*
Create an image 100px high (in the previous example), put the mouseover state in the bottom half, and do this */
#submitButton:hover { background-position: bottom left; }

#2.

Subscribers are not getting sent to 'thank you' page.


Looks like you're submitting to a third party list service, but I don't see a return URL in your form variables. So I'm going to assume it's set in the list service, there are many reasons that could fail. One of them could be the data you're supplying doesn't agree with the expected data at the service end, or a typo somewhere (ThankYou.html is not the same as thank-you.html . . )

Last bit, unrelated, <center> has long been deprecated, try

.center-span {
display: block;
margin:auto;
text-align: center;
}
.center-span input {
/* adjust to taste */
margin-left: 20px;
}

<span class="required center-span">
Name: <input type="text" name="name" value="" size="21">
<br />
Email: <input type=text name=email value="" size="22">
</span>

A better choice would be a paragraph (<p>)