Help, Send email once on a page

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help, Send email once on a page

    Pls any time i view this page the email will be sending to the user that have birthday 4 the day. I want to send the email
    0nce to the user even if the page is viewed many times. Pls help

    PHP Code:
    <?php
    $m
    =date("m");
    $d=date("d");
    ?>
    <?php

    $chek
    =$db->select("SELECT * FROM b_users WHERE month='$m' AND day='$d' ORDER BY userid DESC LIMIT 0,10");


     
     if(
    $chek)
      {
       print 
    "<div class='head'><font size='15'>Today is "

    foreach(
    $chek as $postl)
       {
        if ((
    $d==$postl->day) AND ($m==$postl->month)) echo "<b><a href=\"http://forum.gabbitto.com/profile.php?uid=".$postl->userid."\">".$postl->username."</a></b>, ";
       }
      
    print 
    "birthday</font></div>"

       
    $pmail = new PHPMailer();
       
    $pmail->AddAddress($chek->$email);
       
    $pmail->From $config->adminemail;
       
    $pmail->Subject "Happy birthday ".$chek->username;
     
    $pmail->Body " Happy birthday $chek->username all the memberz of $config->title wishes you an Happy Birthday and a properous years ahead. 
    YOU ARE WELC0ME...<br>
    "
    .$config->title." Team<br><small>Note: Please Don't reply to this email. If you got this email by mistake then ignore this email.</small>";
       
    $pmail->IsHTML(true);
       
    $pmail->Send();

    ?>

    #2
    Originally posted by Wintch View Post
    Pls any time i view this page the email will be sending to the user that have birthday 4 the day. I want to send the email
    0nce to the user even if the page is viewed many times. Pls help

    PHP Code:
    <?php
    $m
    =date("m");
    $d=date("d");
    ?>
    <?php

    $chek
    =$db->select("SELECT * FROM b_users WHERE month='$m' AND day='$d' ORDER BY userid DESC LIMIT 0,10");


     
     if(
    $chek)
      {
       print 
    "<div class='head'><font size='15'>Today is "

    foreach(
    $chek as $postl)
       {
        if ((
    $d==$postl->day) AND ($m==$postl->month)) echo "<b><a href=\"http://forum.gabbitto.com/profile.php?uid=".$postl->userid."\">".$postl->username."</a></b>, ";
       }
      
    print 
    "birthday</font></div>"

       
    $pmail = new PHPMailer();
       
    $pmail->AddAddress($chek->$email);
       
    $pmail->From $config->adminemail;
       
    $pmail->Subject "Happy birthday ".$chek->username;
     
    $pmail->Body " Happy birthday $chek->username all the memberz of $config->title wishes you an Happy Birthday and a properous years ahead. 
    YOU ARE WELC0ME...<br>
    "
    .$config->title." Team<br><small>Note: Please Don't reply to this email. If you got this email by mistake then ignore this email.</small>";
       
    $pmail->IsHTML(true);
       
    $pmail->Send();

    ?>
    instead of running on each page of viewing why don't you try to place code in single file and run a corn job.

    Comment


      #3
      I hav g0ne to my h0sting to check for cron job, and i didnt realy understand it. They said i shud have a knwlodge about linux commands. They just provide a text area 4 me to put my commands, Am lost pls help.
      Last edited by Wintch; 14.07.12, 09:14.

      Comment


        #4
        Originally posted by Wintch View Post
        I hav g0ne to my h0sting to check for cron job, and i didnt realy understand it. They said i shud have a knwlodge about linux commands. They just provide a text area 4 me to put my commands, Am lost pls help.
        The command to run:
        /usr/local/bin/php -f /home/(username)/public_html/(scriptname).php

        Next you'll want to select an option from all the select boxes. Remember to select an option in each box. If you want something to run every day at 4AM, select Minute: 0; Hour: 4; Day: Every; Month: Every; Weekday: Every;

        Comment


          #5
          anil tanx. i used:

          0 0 * * * /usr/local/bin/php -q /home/username/public_html/folder/birthdaymail.php

          Comment


            #6
            Originally posted by Wintch View Post
            anil tanx. i used:

            0 0 * * * /usr/local/bin/php -q /home/username/public_html/folder/birthdaymail.php
            your welcome Wintch

            Comment


              #7
              Originally posted by Peter409
              Pls any time i view this page the email will be sending to the user that have birthday 4 the day.

              don't view the page if you want to view the page then write it separately and link it and don't use sending a mail in that. If you write it every time you are viewing mail will be sent. so put the sending a mail code in another file and that file has to be run as a corn job.

              eg:
              birthday.php -> is your viewing page in that don't put mail.

              create another file like

              alert.php-> in this you have write the retrieving the users and sending a mail to the user who is celebrating b'day.

              sorry, for my bad english.

              Comment


                #8
                why are you using corn job for this , you can do it from mysql , create a remadr alert

                Comment


                  #9
                  xtreme wats the disadvantage of using corn job?

                  Comment

                  Working...
                  X