The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 3 of 3

Thread: Email form limiting submissions?

  1. #1

    Email form limiting submissions?

    I'm trying to create an email form that requires an email address, but only allows a given email address to be sent once per calendar day. If this is too hard, does anyone know of an email service that would block additional email from an email address sent more then once per day?

    Thank you!

  2. #2
    Create a MySQL database with the following tables:

    emails: emailId (auto-increment primary key), address
    sent: emailId, time

    Whenever a mail is being sent do this query (assuming you have a simple database class already):

    PHP Code:
    $db = new DB();

    $q 'SELECT emailId FROM emails WHERE address = ' $addressGuyEntered;
    $q $db->query($q);

    if (
    mysql_num_rows($q) == 0) {
       
    $q 'INSERT INTO emails(address) VALUES('$addressGuyEntered ')';
       
    $q $db->query($q);
       
    $emailId mysql_insert_id();
    }
    else {
       
    $q mysql_fetch_array($q)
       
    $emailId $q['emailId'];
    }

    $q 'SELECT COUNT(*) FROM sent WHERE emailId = "' $emailId 
           
    '" AND time > ' . (60 60 24);
    $q $db->query($q);
    $q mysql_fetch_array($q);

    if (
    $q['COUNT(*)'] >= 1) {
       echo 
    'you have reached the limit of 1 email per day';
    }
    else {
       
    mail($addressGuyEntered'my subject''my message');
       
       
    $q 'INSERT INTO sent(emailId, time) VALUES("' 
               
    $emailId '", "' time() . '")';
       
    $q $db->query($q);

       echo 
    'email has been sent';

    I did not test for syntax errors.

  3. #3
    Thank you. I will try this out!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012