所以我的问题是编码没有插入数据库,日期选择器也有问题。
HTML
<?php
include('connection.php');
include('book.php');
?>
<script language="javascript" type="text/javascript" src="datetimepicker.js">
</script>
</header>
<!-- Main content -->
<section class="row">
<div class="grid">
<label>
Hour of Services
<select name="quantity">
<option value="1" selected>1 hour</option>
<option value="2">1.5 hour</option>
<option value="3">2 hour</option>
<option value="4">2.5 hour</option>
<option value="5">3 hour</option>
</select>
<span id="hourError" class="error"><?php echo $hourError; ?> </span>
</label>
<label>
Choose Date
<input type="Text" id="demo1" maxlength="25" size="25"><a href="javascript:NewCal('demo1','ddmmmyyyy',true,24)"><img src="cal.jpg" width="16" height="16" border="0" alt="Pick a date"></a>
<span class="descriptions">pick a date..</span>
<span id="dateError" class="error2"><?php echo $dateError; ?></span>
</label>
<br>
<label>
Notes
<textarea id="note" onblur="checknote()" name="note"><?php echo $note; ?></textarea>
<span id="noteError" class="error2"><?php echo $noteError; ?></span>
<input class="btn btn-default" type="submit" name="submit" value="booking">
</fieldset>
</form>
</div>
</section>
</body>
</html>
我的php,我的声明有问题吗?
定义变量
$username = "";
$hour = "";
$date = "";
$note = "";
定义错误变量
$usernameError = "";
$hourError = "";
$dateError = "";
$noteError = "";
按下提交按钮时执行此操作
if (isset($_POST['submit'])) {
$username = trim($_POST['username']);
$hour = trim($_POST['hour']);
$date = trim($_POST['date']);
$note = trim($_POST['note']);
我的下拉列表似乎不正确
function checkhour($hour){
global $hourError;
if ($hour === "pleaseselect") {
$hourError = "Please choose an option from the drop down list";
return false;
}
$hourError = "hour select!";
return true;
}
用于检查所有
的功能 function checkAll($username, $hour, $date, $note){
if (checkusername($username) & checkhour($hour) & checknote($note)) {
if(empty($errors)){
$query = "INSERT INTO book (username,hour,date,note) VALUES ('$username','$hour',,'$date''$note')";
$result = mysql_query ($query);
if ($result)
echo "<script language='javascript'>alert ('booked success!'); </script>";
}
checkAll($username, $hour, $date, $note);
}
?>
我不知道,它只是日期,而下拉列表不起作用。请帮忙
答案 0 :(得分:1)
首先使用表单标记包装所有表单元素并设置正确的操作,方法参数。
将选择元素名称属性更改为“小时”
<select name="hour">
将名称属性添加到日期输入字段
<input type="text" id="demo1" maxlength="25" size="25" name="date">
为用户名参数添加输入字段
<input type="text" name="username">