PHP url参数传递给其他php页面

发布于 2024-12-09 06:33:07 字数 3426 浏览 0 评论 0原文

我在通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

掩耳倾听 2024-12-16 06:33:07

我真的不知道你的问题是什么,但尝试 $_REQUEST['....'] 而不是 $_GET['...']。

顺便说一句,您有一个 SQL 注入漏洞:

$booking=$_GET['bookingID'];

将其替换为:

$booking=mysql_escape_string($_GET['bookingID']);

I don't really know what your problem is but try $_REQUEST['....'] instead of $_GET['...'].

By the way, you have a SQL injection vulnerability:

$booking=$_GET['bookingID'];

Replace that with:

$booking=mysql_escape_string($_GET['bookingID']);
我纯我任性 2024-12-16 06:33:07

这里有很多无效的语言用法。您的具体问题:

 '</td><td width="100"><input type="hidden" name="bookingID"
   value="<?php echo $bookingID; ?>" >
 <a href="approve_booking.php?bookingID=".$bookingID." name="REJECT"'

您处于 '单引号' 上下文中,因此 ".$bookingID." 将不起作用。事实上,不正确的双引号只是终止了此处的 HTML 属性。

上面的 在字符串中也不起作用(无论是单引号还是双引号)。

There's a lot of invalid language usage here. Your specific problem:

 '</td><td width="100"><input type="hidden" name="bookingID"
   value="<?php echo $bookingID; ?>" >
 <a href="approve_booking.php?bookingID=".$bookingID." name="REJECT"'

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文