How can I check if an <a>
tag in HTML is clicked in PHP?
I have tried it by if(isset[$_GET[ "idofLink"])
, but in this case, I get the else
statement.
<li class="active"><a name = "profile" href="includes/submit-profile.php">Profile</a></li>
if(isset("profile")){
// Do something....
} else{
// Do something else ...
}
答案 0 :(得分:1)
您应该在链接中添加查询部分,例如... href="includes/submit-profile.php?submit_profile" ...
,以便稍后您可以检查是否单击了链接。所以完整的<li>
元素应该是这样的:
<li class="active"><a name = "profile" href="includes/submit-profile.php?submit_profile">Profile</a></li>
这就是你可以检查是否点击链接的方法:
if(isset($_GET['submit_profile'])){
// do something
}else{
// do something else
}