我有一个PHP页面,下面的代码.MySQL查询工作正常,但我尝试添加一个无效的IF语句.该if(!isset($result))语句应该捕获表只包含FUTURE日期时间值的情况.我显然没有正确使用它,或者我应该使用别的东西 - 比如if(empty())?
<?php
include 'quantitytest_config.php';
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
//select a database to work with
$selected = mysql_select_db("grace59_countdown",$dbhandle)
or die("Could not select countdown");
//execute the SQL query and return records
$result = mysql_query(
"SELECT items
FROM cases
WHERE datetime<=NOW()
Limit 1 ");
// check if there are only future dates in Database
if(!isset($result)){
echo "9999";
} else {
//fetch tha data from the database …Run Code Online (Sandbox Code Playgroud) 我有一个表格,我需要在提交之前填写所有字段。目前,正在验证这些字段以检查它们是否为空白。但是,如果按下提交按钮而没有在表单发送的字段中输入任何值,所有字段都返回空白(例如姓名:电话:等)。我尝试在表单字段中添加 HTML5“必需”属性,但这并不能解决不符合 HTML5 的浏览器或 IE 的问题。
我想知道你是否能帮我解决这个问题...谢谢!
在我的页面顶部,我放了:
<script>
$(function(){
$('#message_form').validate({
submitHandler: function(form) {
$(form).ajaxSubmit({
url: 'process.php',
success: function() {
$('#message_form').hide();
$('#contact_form').append("<p id='message_form_thanks'>Thanks! Your request has been sent.</p>")
}
});
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
process.php 代码是:
<?php
// Get Data
$name = strip_tags($_POST['name']);
$phone = strip_tags($_POST['phone']);
$email = strip_tags($_POST['email']);
$message = strip_tags($_POST['message']);
// $url = strip_tags($_POST['url']);
// Send Message
mail( "mailto:postmaster@domain.com", "Contact Form Submission",
"Name: $name\nPhone: $phone\nEmail: $email\nMessage: $message\n",
"From: Website Form Enquiry <$email>" );
?>
Run Code Online (Sandbox Code Playgroud)
我的表单代码是:
<form id="message_form" method="post"> …Run Code Online (Sandbox Code Playgroud)