douxian5076 2015-03-19 03:52
浏览 14

PHP - 活跃的联系表每天只有2个小时

I'm here first time, and i'd need a little help if it's possible, first of all my english is not good as most of people here, but i'll try to explain what I need

So i have contact form php script on my website, and i want to contact_form work only from 20:30 till 22:00

I have no idea how to do that, here is my php code

<?php
    //Fetching Values from URL
    $name = $_POST['name1'];
    $email = $_POST['email1'];
    $message = $_POST['message1'];
    $contact = $_POST['contact1'];
    //sanitizing email
    $email = filter_var($email, FILTER_SANITIZE_EMAIL);
    //After sanitization Validation is performed
    $subject = $name;
    // To send HTML mail, the Content-type header must be set
    $headers = 'MIME-Version: 1.0' . "
";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
    $headers .= 'From:' . $email. "
"; // Sender's Email
    $headers .= 'Cc:' . $email. "
"; // Carbon copy to Sender
    $template = '<div style="padding:50px; color:white;"><br/>'
    . '<br/>'
    . 'Ime:' . $name . '<br/>'
    . 'IG Ime:' . $email . '<br/>'
    . 'Pjesma:' . $contact . '<br/>'
    . 'Poruka:' . $message . '<br/><br/>';
    $sendmessage = "<div style=\"background-color:#7E7E7E; color:white;\">" . $template . "</div>";
    // message lines should not exceed 70 characters (PHP rule), so wrap it
    $sendmessage = wordwrap($sendmessage, 70);
    // Send mail by PHP Mail Function
    mail("inbox@ug-slike.com", $subject, $sendmessage, $headers);
    echo "Vaša pjesma je naručena! Bit će uskoro emitirana.";
?>

and here is .js

$(document).ready(function(){  
    $("#submit").click(function(){
        var name = $("#name").val();
        var email = $("#email").val();
        var message = $("#message").val();
        var contact = $("#contact").val();

        $("#returnmessage").empty(); //To empty previous error/success message.
        //checking for blank fields 
        if(name==''||contact=='')
        {
           alert("Please Fill Required Fields"); 
        }
        else{
            // Returns successful data submission message when the entered information is stored in database.
            $.post("contact_form.php",{ name1: name, email1: email, message1:message, contact1: contact},
            function(data) {
                $("#returnmessage").append(data);//Append returned message to message paragraph
                if(data=="Your Query has been received, We will contact you soon."){
                    $("#form")[0].reset();//To reset form fields on success
                }
            });
        }
    });
});

I assume that you don't need html code... so, is there anyone who could help me?

If anybody asks himself why I want active only 1:30 - 2 hours a day... it's because that's the time when peoeple will have time to order songs which they wanna listen on online radio where I'm a speaker & radio dj

  • 写回答

1条回答 默认 最新

  • dongxinm279890 2015-03-19 04:48
    关注
    <?PHP
    date_default_timezone_set("Asia/Kolkata");
    $startTime = date("h:i", strtotime("09:30"));
    $endTime = date("h:i", strtotime("11:00"));;
    $currentTime = date("h:i");
    if($startTime < $currentTime && $currentTime < $endTime){
        echo "<input type='submit' name='submit' value='submit'>";
    }
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 我的数据无法存进链表里
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端