You cannot make another post so soon after your last ?

Discussion in 'PHP' started by s.jns, Dec 27, 2010.

  1. #1
    Hi,

    now I am looking for php code that limit for long post after a specified period. so example that after click the send button it will be able to send again after x time long,, this is use for send email to friend. I would appreciate if anyone who gives instructions, this is use for send email to friend.
     
    Last edited: Dec 27, 2010
    s.jns, Dec 27, 2010 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    Something like this might work.

    Place on the form page
    
    session_start();
    $_SESSION["last_email_time"] = time();
    
    PHP:

    Place before you grab the variables sent from the form
    
    session_start();
    if(isset($_SESSION["last_email_time"])){
    $_SESSION["current_time"] = time() - $_SESSION["last_email_time"];
    }
    
    if($_SESSION["current_time"] < 60){ // 60 seconds
    echo("You can't Email more than once every 60 seconds.");
    exit;
    }
    
    PHP:
    Not tested and might need tweaking, it depends on your form action
     
    Last edited: Dec 28, 2010
    MyVodaFone, Dec 28, 2010 IP
  3. dsdf

    dsdf Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Still confuse what do you need. Are you want to automatically send to some email within some time? You can cron job for that task. If you use cpanel on your hosting, choose cron job.
     
    dsdf, Dec 29, 2010 IP