I'm having a problem with an ezine script. I wrote the script so that it sends confirmation emails along with a customized confirmation url that they can go to to confirm. The script simply changes "0" to "1". The url I am using is

http://www.mysite.com/confirm.php?code=m3ny4t36

confirm.php contains:

<? 
include("/config.php"); 
?> 

<?
         if(isset($_GET[code])) {
             if(mysql_query("SELECT * FROM "maileremail" WHERE code='"$_GET[code]"'")) {
                 mysql_query("UPDATE "maileremail" SET active = '1' WHERE code = '"$code"'");
                 echo "Thank you for confirming, you are now added to the list";
             } else {
                 echo "You have the wrong code or id, please double check";
             }
         } else {
             echo "Please use the link in email to confirm your subscription";
         }
         break;
?>

I probably just made a simple mistake as I am new to php but if anyone could check the code out and see what's wrong, I would appreciate it.

    I don't know if this is the problem.
    But when i do this i done this:

             if(isset($_REQUEST[code])) { 
                 if(mysql_query("SELECT * FROM "maileremail" WHERE code='"$_REQUEST[code]"'")) { 
                     mysql_query("UPDATE "maileremail" SET active = '1' WHERE code = '"$_REQUEST['code']"'"); 
    

    instead of this:

             if(isset($_GET[code])) { 
                 if(mysql_query("SELECT * FROM "maileremail" WHERE code='"$_GET[code]"'")) { 
                     mysql_query("UPDATE "maileremail" SET active = '1' WHERE code = '"$code"'"); 
    

    I don't know if that's all

      It still doesn't work. Any other suggestions? I think that it might just be a basic problem that I overlooked because when I go to the url, I get a blank page instead of an error message.

        try this piece:

        <?  
        include("/config.php");
        ?> <? $code = $_REQUEST['code']; if(isset($code)) { if(mysql_query("SELECT * FROM maileremail WHERE code='$code'")) { mysql_query("UPDATE maileremail SET active = '1' WHERE code = '$code'"); echo "Thank you for confirming, you are now added to the list"; } else { echo "You have the wrong code or id, please double check"; } } else { echo "Please use the link in email to confirm your subscription"; } break; ?>

          I get this message:

          Please use the link in email to confirm your subscription
          Fatal error: Cannot break/continue 1 level in E:\home\Default\poultryyouth.com\htdocs\poultry-ezine\confirm.php on line 24
          

          Line 24 is

          break;  

            Then loose the break line :p

              Okay, now I get the message "You have the wrong code or id, please double check"

              I'll post a longer post in a minute with the exact script I used.

                Well, first things first: check if you indeed "have the wrong code or id"

                  Okay, the way the script is designed, someone goes to http://www.poultryyouth.com/index.php or somewhere else on the site where there is a form to join the ezine. Visitors fill in the form, press "subscribe" and the form sends the data to subscribed.php. The script part of subscribed.php is below:

                  <? 
                  function makeRandomPassword() { 
                  $salt = "abchefghjkmnpqrstuvwxyz0123456789"; 
                  srand((double)microtime()*1000000); 
                  $i = 0; 
                  while ($i <= 7) { 
                  $num = rand() % 33; 
                  $tmp = substr($salt, $num, 1); 
                  $pass = $pass . $tmp; 
                  $i++; 
                  } 
                  return $pass; 
                  } 
                  $code = makeRandomPassword(); 
                  ?> 
                  <? $date = date("d. M. Y."); ?>
                  <? $active = ("0"); ?>
                  <?
                  include ("config.php");
                  $insertquery = "INSERT INTO $emailtable (name, email, code, date, active) VALUES ('$name', 
                  '$email', '$code', '$date', '$active')";
                  $insertresult = mysql_query($insertquery);
                  
                  if($insertresult == 1)
                  {
                  ?>
                  You have successfully subscribed to the PYA's Ezine.<p>
                  <p>Go back to the last page by clicking <a href="javascript:history.go(-1)">Here</a>
                  <?
                  }
                  else
                  {
                  ?>
                  Something went wrong while entering your email address into the database. Please make sure that you entered the correct name and email address and <a href="javascript:history.go(-1)">try again</a>. If you continue having problems, please contact the administrator at <a href="mailto:<?echo $mailinglist_administrator;?>"><?echo $mailinglist_administrator;?></a>.<p>
                  <?
                  }
                  ?>
                  <?
                  $recipient = ("$email");
                  $subject = ("Confirmation Email");
                  $msg = ("Thank you for subscribing to the PYA's free Poultry Ezine. To confirm your subscription, please go to  [url]http://www.poultryyouth.com/poultry-ezine/confirm.php?code=[/url]$code If you did not subscribe to the PYA's mailing list, please ignore this email and accept our apologies. Thank you.
                  
                  You subscribed as $name $email on $date");
                  $mailheaders = ("From: Poultry Youth of America \n Reply-To: [email]someone@poultryyouth.com[/email]\n\n");
                  
                  
                    mail($recipient, $subject, $msg, $mailheaders); 
                  ?>

                  As you can see, subscribed.php generates a random code, puts the name, email, code, and date into the database, and sends a confirmation email to the subscriber with a url that contains the code in it. The url is in "http://www.poultryyouth.com/poultry-ezine/confirm.php?asdf" format. Confirm.php is below:

                  <? include("/config.php"); ?>   
                  <?
                  $code = $_REQUEST['code']; if(isset($code)) {
                  if(mysql_query("SELECT * FROM maileremail WHERE code='$code'")) {
                  mysql_query("UPDATE maileremail SET active = '1' WHERE code = '$code'");
                  echo "Thank you for confirming, you are now added to the list";
                  } else {
                  echo "You have the wrong code or id, please double check";
                  }
                  } else {
                  echo "Please use the link in email to confirm your subscription";
                  };
                  ?>

                  Confirm.php is supposed to change "active" to 1. I think that this is where I am running into trouble with this script. I am currently getting the "You have the wrong code or id, please double check" error message.

                  Any help appreciated...

                    Write a Reply...