diff options
author | prashant | 2015-09-30 18:07:51 +0530 |
---|---|---|
committer | prashant | 2015-09-30 18:07:51 +0530 |
commit | 0a589b4544c6016dc9f8132a6a08f56d271944df (patch) | |
tree | cf1c31ee62c84cf9ab1aea301233282d04f31b41 | |
parent | 1361aa53c4eaec8b79c6a5834a6192e4fc0d49cd (diff) | |
download | HTML-Email-Invitations-0a589b4544c6016dc9f8132a6a08f56d271944df.tar.gz HTML-Email-Invitations-0a589b4544c6016dc9f8132a6a08f56d271944df.tar.bz2 HTML-Email-Invitations-0a589b4544c6016dc9f8132a6a08f56d271944df.zip |
added PDO in sql query
-rwxr-xr-x | unsubscribe.php | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/unsubscribe.php b/unsubscribe.php index 85bc80e..f72f49a 100755 --- a/unsubscribe.php +++ b/unsubscribe.php @@ -3,9 +3,9 @@ require_once('connection.inc'); header('Refresh: 3; URL=http://scipy.in'); if(isset($_GET) && isset($_GET['key'])){ - + unsubscribeEmailid($_GET['key']); - + }else{ echo 'wrong link'; @@ -13,38 +13,48 @@ echo 'wrong link'; function unsubscribeEmailid($email_id_hash) { - global $conn; - + // try to update user with specified information - $sql = "SELECT email, unsubscribe, email_hash FROM sent_email WHERE email_hash ='".$email_id_hash."'"; - $result = $conn->query($sql); - $row = $result->fetch_assoc(); - - if($row != NULL){ - + $sql = "SELECT email, unsubscribe, email_hash FROM sent_email WHERE email_hash = :email_id_hash "; + $q = $conn->prepare($sql); + $q->execute(array('email_id_hash'=>$email_id_hash)); + + + while($data = $q->fetchAll(PDO::FETCH_ASSOC)) { + foreach($data as $row){ + + + if($data != NULL){ + if($row['unsubscribe'] == 0 && $row['email_hash'] == $email_id_hash){ - $query="UPDATE sent_email SET unsubscribe = 1 WHERE email_hash ='". $email_id_hash."'"; - $result = $conn->query($query); - + + $sql_up = "UPDATE sent_email SET unsubscribe = 1 WHERE email_hash =:email_id_hash "; + $q_up = $conn->prepare($sql_up); + $q_up->execute(array(':email_id_hash'=>$email_id_hash)); + echo '<br>Thank You for unsubscription'; echo '<br><br>If you are not automatically redirected, click here: <a href="http://scipy.in">SciPy India 2015</a>.'; } - + elseif($row['unsubscribe'] == 1 && $row['email_hash'] == $email_id_hash){ echo '<br>You are already unsubscribed!'; - echo '<br><br>If you are not automatically redirected, click here: <a href="http://scipy.in">SciPy India 2015</a>.'; + echo '<br><br>If you are not automatically redirected, click here: <a href="http://scipy.in">SciPy India 2015</a>.'; } - + else{ echo '<br>You are not a subscriber!'; echo '<br><br>If you are not automatically redirected, click here: <a href="http://scipy.in">SciPy India 2015</a>.'; - } - + } + }else{ - + echo "Wrong Link please try again"; - }} -$conn->close(); + } + } + } +} + +$conn=null; ?> |