//, PHP/Publishing Newsletters Using PHP & MySQL – 3

Publishing Newsletters Using PHP & MySQL – 3

Publishing Newsletter Using PHP & MySQL – 3

For a quick wrap of the previous articles in the current series, go to:

Part 1

Part 2

By the end of the previous article we sent a verification email to whomever submits the subscription form. The email should contain the following message:

Please click on


If the person clicks on the link, the subsequent procedure verifies the email. So now let us write vemail.php.




$db=mysql_connect(“localhost”, $user_name, $pwd) or

die(“I cannot connect to the database because ” .


mysql_select_db(“newslet”, $db);


The above code has already been explained in http://www.bytesworth.com/learn/php00002.asp. If the person actually submitted the email, this email should be there in the database with the field active set to 0. The following commands set active to 1 if the email “name@somesite.com” exists in the table “subscribers”.




This command fetches the “GET” variable from the URL. If you are used to fiddling with forms you must be femiliar with using method=”post” and method=”get”. If not, go to http://www.bytesworth.com/learn/html00009.asp for a proper enlightenment on the subject. We move forward.


$query=”update subscribers set active=1 where email='” . $email . “‘”;


See that you enclose email in single quotes.




Whenever an SQL query is executed (the Talibanis just executed 8 Pakistani soldiers, so I find this word very violent), it affects one or more rows. If the email exists and if its respective active field is 0, then at least one row should be affected.




  echo “<h1>Congratulations!</h1>”;

  echo “<p>Your email has been verified.</p>”;




  echo “<p>Sorry! You have either already verified your email, or you haven’t submitted your details for verification. Please go to the form and submitted your details.</p>”;



This ends the verification. In the fourth (perhaps the final of this series) article, we’ll see how the database is used to finally send the newsletter.

2010-05-26T17:04:55+00:00 March 28th, 2004|MySQL, PHP|0 Comments

About the Author:

Amrit Hallan is a freelance web developer. You can checkout his website at http://www.bytesworth.com. For more such articles join BYTESWORTH REACHOUT at http://www.bytesworth.com/br/default.asp or if you have a web dev related question then post it at http://www.business180.com/index.php

Leave A Comment