2011-10-12 3 views
-2

url 매개 변수를 통해 다른 페이지로 값을 전달하는 데 문제가 있습니다. REJECT 버튼을 클릭하여 선택한 예약 ID를 기반으로 예약을 거부하고 싶습니다.PHP URL 매개 변수가 다른 PHP 페이지로 전달 중

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

    } 



?> 
+0

그리고 문제는 무엇입니까? – matino

+0

질문이 누락되었습니다 :) –

+0

1) SQL 인젝션주의 2) 특히 dev 환경에서 오류 서프 레서 제거 3) 어떻게 쿼리 문자열을 전달합니까? 나는 부러진/불완전한 형태만을 본다. GET 메소드를 사용하는 경우 2 개의 POST가 생성됩니다. 4) 실제로, 당신의 질문은 실제로 무엇입니까? –

답변

0
:하지만 bookingID 값이 다른 페이지로 전달하지 않습니다, URL은 다음이 http://localhost/tablesortapprovebook/approve_booking.php?bookingID=

내 코딩 세그먼트처럼 나타납니다

당신의 문제가 무엇인지 모르겠지만 $ _REQUEST [ '....'] 대신 $ _GET [ '...']을 사용해보십시오.

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

잘못된 언어 사용의 많은 여기에있다 :

$booking=$_GET['bookingID']; 

과 함께 그 교체 : 그런데

, 당신은 SQL 주입 취약점을 가지고있다. 귀하의 특정 문제 :

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

당신은 ' 따옴표 ' 맥락에서, 그리고 ".$bookingID." 따라서 작동하지 않습니다. 실제로 잘못된 이중 따옴표는 HTML 속성을 여기에서 종료합니다.

위의 <?php echo...은 문자열 내에서 작동하지 않습니다 (큰 따옴표 또는 큰 따옴표 포함 안함).

관련 문제