PDA

View Full Version : How to write a script for stopping double opt-in ? Thanks.



Manicui
Mar 10th, 2008, 02:03 PM
Hi everyone,

Good day to you.

I need a script to stop people from double opt-in for the same subscription on my webform.In general,if a visitor to my site had filled in the opt-in form follow by the submission for the subscription to my newsletter,he will never be subscribe to the same opt-in again.The system will be able to detect it with a message show to him - you had been subscribed to this opt-in when he try to fill in and submit the same opt-in in near future.

However,I need your advice on how to get it done with the following scripts from my webform code. How to write this script ? Where to insert it in my webform code ?

--------------------------------------------------------------------------

<script language="javascript">

function verify()
{

var errors1 = "";
var errors2 = "";
var errors3 = "";
var message="Please complete the following field(s): \n";

var first = document.myform.realname.value;
var last = document.myform.lastname.value;
var email = document.myform.email.value;

if (first.length == "0") {
errors1="First name\n";
}
if (last.length == "0") {
errors2="Last name\n";
}
if (email.length == "0") {
errors3="email address\n";
}
if (errors1.length >= "1" || errors2.length >= "1" || errors3.length >= "1") {
alert(message + "\n\n" + errors1 + errors2 + errors3);
}
else {
document.myform.submit();
}
}


function verify2()
{

var errors1 = "";
var errors2 = "";
var errors3 = "";
var message="Please complete the following field(s): \n";

var first = document.myform2.realname.value;
var last = document.myform2.lastname.value;
var email = document.myform2.email.value;

if (first.length == "0") {
errors1="First name\n";
}
if (last.length == "0") {
errors2="Last name\n";
}
if (email.length == "0") {
errors3="email address\n";
}
if (errors1.length >= "1" || errors2.length >= "1" || errors3.length >= "1") {
alert(message + "\n\n" + errors1 + errors2 + errors3);
}
else {
document.myform2.submit();
}
}

</script>

</head>

<body>


<!-- First Form -->

<form name="myform" METHOD="post" ACTION="http://yourdomain.com/cgi-bin/formmail.pl">
<input type=hidden name="recipient" value="[email protected]">
<input type=hidden name="subject" value="Your Subject">
First Name :
<input type=text name="realname" size="20">


Last Name :
<input type=text name="lastname" size="20">


Email&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :
<input type=text name="email" size="20">


<input type="button" value="submit" onclick="verify()"/>

</form>
<p>Important:I will never share your information with anyone !</p>


<BR><BR><!-- REMOVE THESE LINE BREAKS - FOR DEMO ONLY --><BR><BR>


<!-- Second Form -->

<form name="myform2" METHOD="post" ACTION="http://yourdomain.com/cgi-bin/formmail.pl">
<input type=hidden name="recipient" value="[email protected]">
<input type=hidden name="subject" value="Your Subject">
First Name :
<input type=text name="realname" size="20">


Last Name :
<input type=text name="lastname" size="20">


Email&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :
<input type=text name="email" size="20">


<input type="button" value="submit" onclick="verify2()"/>

</form>
--------------------------------------------------------------------------

Many thanks for your time and effort in helping me.

Thank you.

Best regards
Manicui

Philip M
Mar 10th, 2008, 02:19 PM
JavaScript is purely a client-side language, and has no capability to read information from or write to a file (except a cookie), access a database or the client's operating system.

This means that you can only prevent double-subscription by using a server-side language such as PERL or PHP.

It would not help to set a cookie on the user's machine, as the user could simply delete it.

Manicui
Mar 10th, 2008, 02:30 PM
Hi Philip M,

Many thanks for your replied to my queries over double opt-in issue.

You mentioned that to prevent double-subscription by using a server-side language such as PERL or PHP.

Unfortunatly,I don't have any knowledge of perl and php,can you help me and provide a solution to me ?

Thank you.

Best regards
Manicui

Philip M
Mar 10th, 2008, 04:17 PM
You are posting your form to formmail.pl (PERL) but you will need at the minimum a data file containing the list of the subscribers.

If you have no knowledge of PERL then I am afraid that not a lot can be done - this forum is not a free coding service or an arm of social security.

The best you can do is maintain the list of subscribers in your Outlook Express address book, which will warn you if you try to include the same address twice. Then you can manually email the subscriber to point out that he has already subscribed to your newsletter.

Have a look at www.hotscripts.com - there are many pre-made scripts offered there.

This one may suit you: http://www.americanfinancing.net/afc-simple-newsletter.cfm