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

时间:2015-03-19 03:52:28

标签: javascript php html

我第一次来这里,如果可能的话我需要一些帮助,首先我的英语不像这里的大多数人一样好,但是我会试着解释我需要的东西

所以我在我的网站上有联系表格php脚本,我想联系表格工作时间从20:30到22:00

我不知道该怎么做,这是我的PHP代码

<?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' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From:' . $email. "\r\n"; // Sender's Email
    $headers .= 'Cc:' . $email. "\r\n"; // 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.";
?>

这里是.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
                }
            });
        }
    });
});

我认为你不需要HTML代码......所以,有没有人可以帮助我?

如果有人问自己为什么我想活动一天只有1:30 - 2小时......那是因为那时peoeple有时间订购他们想要在线收听的歌曲收音机,我和扬声器电台dj

1 个答案:

答案 0 :(得分:3)

<?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'>";
}
?>