Jump to content

Mail message depends on nr of people.


wannes

Recommended Posts

My apologize if this should be here since this involves SQL.

 

My user can register himself ( just an email ) to a mail list.

He will get a mail after that, but the message in the mail should differ:

If there are under 100 people in the DB he should get something like " you are one of the 100 first people ", if there are more then 100 people it should say " sorry, to late ".

 

I can seem to get it to work so help would be awesome

( ps, I kinda need an anwser fast :s )

$sqlInsert = "INSERT INTO j5_maillist (email) VALUES('$email')";

        $sql = "SELECT COUNT(email) FROM j5_maillist AS aantalEmails";
        $result = mysql_query($sql);


        if( mysql_num_rows($result) <= "3" ){
             $message = 'you are one of the 100 first people  ';
    } else {
             $message = 'sorry, to late  ';
}

        $to      = $email;
        $subject = 'Nihonto Appreciation Day';
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

            // Additional headers
        $headers .= 'To: '.$email.'' . "\r\n";
        $headers .= 'From: Nihonto Appreciation Day' . "\r\n";

        mail($to, $subject, $message, $headers);

        return mysql_query($sql);

 

Link to comment
https://forums.phpfreaks.com/topic/250572-mail-message-depends-on-nr-of-people/
Share on other sites

You set if count = or less than three it would let him register

 


<?        $sql = "SELECT COUNT(email) FROM j5_maillist AS aantalEmails";
        $result = mysql_query($sql);


        if( mysql_num_rows($result) <= "3" ){
             $message = 'you are one of the 100 first people  ';
    } else {
             $message = 'sorry, to late  ';
}
?>

 

You should set that to 100

 

if( mysql_num_rows($result) <= "100" ){

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.