Par*_*ody 4 javascript php mysql isset
isset()函数可用于检查是否按下了输入类型提交,但有没有办法检查是否按下了输入类型按钮?在我的代码中,该按钮除了调用.Onclick()事件上的函数之外什么都不做,然后刷新页面并在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());
}
?>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
42169 次 |
| 最近记录: |