多个html href到php页面
我有一个html页面多个html href到php页面,php,html,Php,Html,我有一个html页面 <html> <head> </head> <body> <form> <div><a href="MySubmissionView.php">Number of Applications:</a></div> <div><a href="MySubmission
<html>
<head>
</head>
<body>
<form>
<div><a href="MySubmissionView.php">Number of Applications:</a></div>
<div><a href="MySubmissionView.php">Submitted Applications:</a></div>
</form>
</body>
</html>
我有一个php页面“MySubmissionView.php”,用于一些进程。
在我的php页面中,我如何知道我点击了哪个链接?提前感谢
<div><a href="MySubmissionView.php?id=xx1">Number of Applications:</a></div>
<div><a href="MySubmissionView.php?id=xx2">Submitted Applications:</a></div>
Php页面:
if (!empty($_GET['id'])) {
echo '<p>The id is: '.$_GET['id'].'</p>';
// do something else
}
if(!empty($\u GET['id'])){
echo'id是:'.$\u GET['id'.'.';
//做点别的
}
Php页面:
if (!empty($_GET['id'])) {
echo '<p>The id is: '.$_GET['id'].'</p>';
// do something else
}
if(!empty($\u GET['id'])){
echo'id是:'.$\u GET['id'.'.';
//做点别的
}
向HREF添加查询字符串。e、 g.MySubmissionView.php?page=number,MySubmissionView.php?page=submitted。您可以使用$\u GET('paramname')
从php访问查询字符串。下面是一个例子:
HTML:
<html>
<head>
</head>
<body>
<form>
<div><a href="MySubmissionView.php?page=number">Number of Applications:</a></div>
<div><a href="MySubmissionView.php?page=submitted">Submitted Applications:</a></div>
</form>
</body>
</html>
if (isset($_GET['page']))
if($_GET['page'] == 'number') {
// process page number here
} elseif($_GET['page'] == 'submitted') {
// process page submitted here
}
}
向HREF添加查询字符串。e、 g.MySubmissionView.php?page=number,MySubmissionView.php?page=submitted。您可以使用
$\u GET('paramname')
从php访问查询字符串。下面是一个例子:
HTML:
<html>
<head>
</head>
<body>
<form>
<div><a href="MySubmissionView.php?page=number">Number of Applications:</a></div>
<div><a href="MySubmissionView.php?page=submitted">Submitted Applications:</a></div>
</form>
</body>
</html>
if (isset($_GET['page']))
if($_GET['page'] == 'number') {
// process page number here
} elseif($_GET['page'] == 'submitted') {
// process page submitted here
}
}
将检查页面是否收到GET/Post请求
将检查页面是否收到GET/Post请求 添加查询字符串。e、 g.MySubmissionView.php?page=number和MySubmissionView.php?page=submitted@HenriHietala您应该将其发布为应答并添加查询字符串。e、 g.MySubmissionView.php?page=number和MySubmissionView.php?page=submitted@HenriHietala您应该将其作为应答发布冗余,
empty()
已检查变量是否已设置。冗余,empty()
已检查变量是否已设置+1对于previus的评论,作为个人意见,我将把isset()
更改为!empty()
+1用于previus注释,作为个人意见,我将把isset()
更改为!空()
<?php
$go = "";
if(isset($_GET)){
if(isset($_GET['go'])){
$go = $_GET['go'];
}else{
// do something if '$_GET['go']' is not set
}
}else{
// Do something if u don't get a $_GET Request
}
echo 'Clicked Page'.$go;
?>
if(isset($_GET))