PHP url参数传递给其他php页面
我在通过 url 参数将值传递到其他页面时遇到问题。我想通过单击“拒绝”按钮来拒绝基于所选 bookingID 的预订。但 bookingID 值不会传递到其他页面,网址显示如下 http://localhost/tablesortapprovebook/ ?bookingID=
这是我的编码段:
index.phpapprove_booking.php
<head>
<script src="jquery-latest.js" type="text/javascript"></script>
<script src="jquery.tablesorter.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
$("#myTable").tablesorter({widgets: ['zebra']});
});
$(document).ready(function()
{
$("#myTable").tablesorter();
}
);
$(document).ready(function()
{
$("#myTable").tablesorter( {sortList: [[0,0], [1,0]]} );
}
);
</script>
<link href="style.css" rel="stylesheet" type="text/css">
<link href="stylelogin.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
include("dbconfig.php");
$query = "SELECT customer.companyName, customer.contactName, eventinfo.eventTitle,boothAlias,date, testbook.bstatus, testbook.username, bookingID from eventinfo, testbook, customer where testbook.username=customer.username AND testbook.eventID=eventinfo.eventID";
$o = '<table id="myTable" class="tablesorter" width="930px"><thead><tr><th>Company Name</th><th>Contact Name</th><th>Event</th><th>Booth</th><th>Date</th><th>Status</th></tr></thead><tbody>';
$result = mysql_query($query);
while($row=mysql_fetch_array($result))
{
$boothAlias=stripslashes($row["boothAlias"]);
$eventTitle=stripslashes($row["eventTitle"]);
$date=stripslashes($row["date"]);
$bstatus=stripslashes($row["bstatus"]);
$companyName=stripslashes($row["companyName"]);
$contactName=stripslashes($row["contactName"]);
$bookingID=stripslashes($row["bookingID"]);
if($bstatus==0){
$status="Pending";
}else if($bstatus==1){
$status="Successful";
}else{
$status="Reject";
}
$o .= '<tr><td width="120px">'.$companyName.'</td><td width="120px">'.$contactName.'</td><td width="180px">'.$eventTitle.
'</td><td width="70px">'.$boothAlias.'</td><td width="170px">'.$date.'</td><td width="70">'.$status.'</td><td>'.$bookingID.'
</td><td width="100"><input type="hidden" name="bookingID" value="<?php echo $bookingID; ?>" ><a href="approve_booking.php?bookingID=".$bookingID.
" name="REJECT" id="REJECT"><input width="100px" name="REJECT" type="submit" id="REJECT" value="Reject"></a></td></tr>';
}
$o .= '</tbody></table>';
echo $o;
?>
</body>
approve_booking.php
<?php
mysql_connect("localhost", "root", "") or die (mysql_error());
mysql_select_db("eventdb") or die (mysql_error());
$booking=$_GET['bookingID'];
echo $booking;
if(isset($_POST['APPROVED']))
{
$query2 = "UPDATE testbook SET bstatus ='0' WHERE bookingID='$booking'";
$result2 = @mysql_query($query2);
}
if (isset($_POST['REJECT']))
{
$query3 = "UPDATE testbook SET bstatus ='2' WHERE bookingID='$booking'";
$result3 = @mysql_query($query3);
}
?>
I have problem to pass value via url parameter to other page. I want to reject a booking based on selected bookingID by clicking REJECT button. But the bookingID value do not pass to other page, the url appear like this http://localhost/tablesortapprovebook/approve_booking.php?bookingID=
Here is my coding segment:
index.php
<head>
<script src="jquery-latest.js" type="text/javascript"></script>
<script src="jquery.tablesorter.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
$("#myTable").tablesorter({widgets: ['zebra']});
});
$(document).ready(function()
{
$("#myTable").tablesorter();
}
);
$(document).ready(function()
{
$("#myTable").tablesorter( {sortList: [[0,0], [1,0]]} );
}
);
</script>
<link href="style.css" rel="stylesheet" type="text/css">
<link href="stylelogin.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
include("dbconfig.php");
$query = "SELECT customer.companyName, customer.contactName, eventinfo.eventTitle,boothAlias,date, testbook.bstatus, testbook.username, bookingID from eventinfo, testbook, customer where testbook.username=customer.username AND testbook.eventID=eventinfo.eventID";
$o = '<table id="myTable" class="tablesorter" width="930px"><thead><tr><th>Company Name</th><th>Contact Name</th><th>Event</th><th>Booth</th><th>Date</th><th>Status</th></tr></thead><tbody>';
$result = mysql_query($query);
while($row=mysql_fetch_array($result))
{
$boothAlias=stripslashes($row["boothAlias"]);
$eventTitle=stripslashes($row["eventTitle"]);
$date=stripslashes($row["date"]);
$bstatus=stripslashes($row["bstatus"]);
$companyName=stripslashes($row["companyName"]);
$contactName=stripslashes($row["contactName"]);
$bookingID=stripslashes($row["bookingID"]);
if($bstatus==0){
$status="Pending";
}else if($bstatus==1){
$status="Successful";
}else{
$status="Reject";
}
$o .= '<tr><td width="120px">'.$companyName.'</td><td width="120px">'.$contactName.'</td><td width="180px">'.$eventTitle.
'</td><td width="70px">'.$boothAlias.'</td><td width="170px">'.$date.'</td><td width="70">'.$status.'</td><td>'.$bookingID.'
</td><td width="100"><input type="hidden" name="bookingID" value="<?php echo $bookingID; ?>" ><a href="approve_booking.php?bookingID=".$bookingID.
" name="REJECT" id="REJECT"><input width="100px" name="REJECT" type="submit" id="REJECT" value="Reject"></a></td></tr>';
}
$o .= '</tbody></table>';
echo $o;
?>
</body>
approve_booking.php
<?php
mysql_connect("localhost", "root", "") or die (mysql_error());
mysql_select_db("eventdb") or die (mysql_error());
$booking=$_GET['bookingID'];
echo $booking;
if(isset($_POST['APPROVED']))
{
$query2 = "UPDATE testbook SET bstatus ='0' WHERE bookingID='$booking'";
$result2 = @mysql_query($query2);
}
if (isset($_POST['REJECT']))
{
$query3 = "UPDATE testbook SET bstatus ='2' WHERE bookingID='$booking'";
$result3 = @mysql_query($query3);
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我真的不知道你的问题是什么,但尝试 $_REQUEST['....'] 而不是 $_GET['...']。
顺便说一句,您有一个 SQL 注入漏洞:
将其替换为:
I don't really know what your problem is but try $_REQUEST['....'] instead of $_GET['...'].
By the way, you have a SQL injection vulnerability:
Replace that with:
这里有很多无效的语言用法。您的具体问题:
您处于
'
单引号'
上下文中,因此".$bookingID."
将不起作用。事实上,不正确的双引号只是终止了此处的 HTML 属性。上面的
在字符串中也不起作用(无论是单引号还是双引号)。
There's a lot of invalid language usage here. Your specific problem:
You are in
'
single quote'
context, and the".$bookingID."
thus won't work. In fact the incorrect double quote just terminates the HTML attribute here.The
<?php echo...
above will also not work within a string (regardless if single or double quoted).