isset()函數可用於檢查是否按下輸入類型提交,但是有什麼方法檢查輸入類型按鈕是否被按下?在我的代碼中,按鈕除了在.Onclick()事件上調用一個函數,然後刷新頁面並在php中創建一個數據庫條目...並且我希望它只在按下按鈕後才能輸入條目......並且我不能使用提交類型的其他原因...以下是一些代碼:如何檢查輸入類型按鈕是否在PHP中按下?
function send()
{
var events=document.getElementById("event").value;
location.href="calm.php?day=" + xx + "&month=" + yy + "&year=" + zz + "&events=" + events;
}
<input name="Button" type="button" id="submit" onclick="send(this.form)" value="Button" />
<?php
session_start();
include_once "connect_to_mysql.php";
$day = $_GET['day'];
$month = $_GET['month'];
$year = $_GET['year'];
$events = $_GET['events'];
$userid = $_SESSION['id'];
if (isset($_POST['button']))
{
$sql = mysql_query("INSERT INTO events (userid,month,day,year,events)
VALUES('$userid','$month','$day', '$year','$events')")
or die (mysql_error());
}
?>