Jump to content

How to stop people from double opt-in ?


moneytree

Recommended Posts

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="newsletter@yourdomain.com"><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           :<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="FreeEbook@yourdomain.com"><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           :<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 regardsManicui

Link to comment
Share on other sites

I assume that you have a database that you're storing all of this information in. I'm not sure how someone subscribes, I assume it's by email address. So you would use PHP to check in your database to see if their email address exists (after they enter it), and if so you would show one thing, or else show the form to opt in if it wasn't in the database.

Link to comment
Share on other sites

Hi Justsomeguy,Goog day to you.I am sorry for didn't provide a clear picture to you for my request.Infact,the webform code posted for your review and advice is done with the helped from someone in the forum.Currently,I don't have any database as my web site haven't luanch yet due to double opt-in issue. There're firstname,lastname and email address on my webform to collect the opt-in data. Therefore,the double opt-in function will check against this information.I am learning html at the moment,therefore,php is alien to me.Referring to your advice - you would use PHP to check in your database to see if their email address exists (after they enter it), and if so you would show one thing, or else show the form to opt in if it wasn't in the database.May I have a request from you ? Is it alright for you to show me the php code which is the solution to my double opt-in issue ?Many thanks for your time and effort in helping me.Best regardsManicui

Link to comment
Share on other sites

If you don't have a database then there isn't any code. You will need to save the details that get submitted into a database. I don't think formmail.pl is going to be able to do that. If you want to keep track of who already filled out the form then you will need to rewrite it to use PHP and a database instead of formmail.pl. This would be an example, yours would look something like this:

<?phpmysql_connect("host", "user", "password");mysql_select_db("database");$email = $_POST['email'];$fname = $_POST['realname'];$lname = $_POST['lastname'];$result = mysql_query("SELECT * FROM optins WHERE email = '" . mysql_real_escape_string($email) . "'");if (mysql_num_rows($result) > 0){  // they have already opted in}else{  // they have not opted in, so add them to the database}?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...