php检查是否单击了链接
问题是,如何检查链接是否已被单击php检查是否单击了链接,php,html,dreamweaver,Php,Html,Dreamweaver,问题是,如何检查链接是否已被单击 <a href="laggtill.php">+</a> <a href="laggtill.php">+</a> (another document) <?php session_start(); $_SESSION['car'] = $_SESSION['car'] + 1; $_SESSION['boat'] = $_SESSION['boat'] + 1; header("Location: b
<a href="laggtill.php">+</a>
<a href="laggtill.php">+</a>
(another document)
<?php
session_start();
$_SESSION['car'] = $_SESSION['car'] + 1;
$_SESSION['boat'] = $_SESSION['boat'] + 1;
header("Location: betalning.php");
?>
(另一份文件)
第一个标签将汽车添加到购物车,第二个标签将船添加到购物车。如何检测已单击的标记中的哪一个,若现在单击任何一个标记,则汽车和船都将添加到购物车中。您可以向链接添加GET参数:
<a href="laggtill.php?add=car">Add car</a>
这基本上是使用链接将数据从一个页面传递到另一个页面的最简单方法。您应该使用的概念。是Ajax 浏览器的每次单击和其他操作仅在客户端(浏览器)上发生
一些简单的例子可能是: //Html
<a id="linkone" href="laggtill.php">+</a>
<a id="linktwo" href="laggtill.php">+</a>
//第一个链接的php文件
<?php
//capture values
// But only is a clic, then there is not values
session_start();
$_SESSION['car'] = $_SESSION['car'] + 1;
// If you want some simple, one file only works for one link
// For the other link, you should create other file same to this.
header("Location: betalning.php"); // With ajax dont use this line,
?>
您希望通知页面还是服务器?这就是你要找的吗?
// Use jquery
$("#linkone").on("click", function(){
//function that send request to server
$.post('someurl.php', {})
.success(function(res){
console.log(res);
// If you stay here, the procces should be ended
})
// if you return false, the click dont redirect other window
// if you return true, the click redirect other window
return false;
});
<?php
//capture values
// But only is a clic, then there is not values
session_start();
$_SESSION['car'] = $_SESSION['car'] + 1;
// If you want some simple, one file only works for one link
// For the other link, you should create other file same to this.
header("Location: betalning.php"); // With ajax dont use this line,
?>