gpt4 book ai didi

javascript - PHP - 主动联系表每天仅需 2 小时

转载 作者:行者123 更新时间:2023-11-28 19:19:29 24 4
gpt4 key购买 nike

我是第一次来这里,如果可能的话,我需要一点帮助,首先,我的英语不像这里的大多数人那么好,但我会尽力解释我需要什么

所以我的网站上有联系表单 php 脚本,并且我希望 contact_form 仅在 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 小时...那是因为在这个时候人们有时间在我担任演讲者的在线广播上订购他们想听的歌曲&电台DJ

最佳答案

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

关于javascript - PHP - 主动联系表每天仅需 2 小时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29136937/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com