Add to cart
하이퍼 링크를 클릭하면 cart.php 페이지가 응답하지 않습니다 (하이퍼 링크가 잘 보이지만 cart.php에 문제가 있습니다). . 사전에 감사합니다 감사합니다다른 페이지로의 하이퍼 링크가 작동하지 않습니다
<html>
<head>
</head>
<body>
<table>
<tr>
<td><?php echo $row['ISBN']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['title']; ?></td>
<td><?php echo $row['year']; ?></td>
<td><?php echo $row['price']; ?></td>
<td><?php echo $row['publisher']; ?></td>
<td> <a href="cart.php?add=abc">Add to cart</a></td>
<td><?php echo $row['ISBN']; ?></td>
</tr>
</table>
</body>
</html>
cart.php 페이지 :.
<?php
//
session_start();
$page = 'search.php';
$lpage = 'cart.php';
$db = new mysqli('localhost', 'root', '', 'cheapbook') or die('Error connecting to MySQL server.');
mysqli_set_charset($db, 'utf8');
if (isset($_GET['add'])) {
echo $_GET['add'];
$pieces = explode(":", $_GET['add']);
$quantity = mysqli_query('SELECT ISBN, title from book WHERE ISBN=$pieces[0]');
$result = mysqli_query($db, $quantity);
while ($quantity_row = mysqli_fetch_array($result)) {
if ($quantity_row['quantity'] != $_SESSION['cart_' . $_GET['add']]) {
$_SESSION['cart_' . $_GET['add']] += 1;
}
}
if ($pieces[1] == 'SearchByBookTitle') {
header('location:' . $page . 'SearchByBookTitle=' . $pieces[2]);
}
if ($pieces[1] == 'SearchByAuthor') {
header('location:' . $page . 'SearchByAuthor=' . $pieces[2]);
echo $pieces[1];
} else {
header('location:' . $lpage);
}
}
if (isset($_GET['remove'])) {
$_SESSION['cart_' . $_GET['remove']]--;
header('location:' . $page);
}
if (isset($_GET['delete'])) {
$_SESSION['cart_' . $_GET['remove']]--;
header('location:' . $page);
}
if (isset($_GET['cart'])) {
cart();
}
function cart()
{
foreach ($_SESSION as $name => $value) {
if ($value > 0) {
if (substr($name, 0, 5) == 'curt_') {
$total = 0;
$id = substr($name, 5, (strlen($name) - 5));
$get = mysql_query("SELECT ISBN, title, price FROM book where id='.$id.'");
$result = mysqli_query($db, $get);
while ($get_row = mysqli_fetch_array($result)) {
$sub = $get_row['price'] * $value;
echo $get_row['title'] . 'X' . $value . '@Dollar' . $get_row['price'] . '=' . $sub . '<a href="cart.php?remove=.$id.">[-]</a><a href="cart.php?add=.$id.">[+]</a><a href="cart.php?delete=.$id.">[Delete]</a>';
}
$total += $sub;
}
}
if ($total == 0) {
echo "Your cart is empty";
} else {
echo "Paypal button";
}
}
}
?>
페이지 로딩은 무엇입니까? 실제 코드는 무엇인가?'abc'는':'이 없기 때문에 여러분의 가치가 될 수 없습니다. 또한이 코드를 사용하여 SQL 인젝션을 사용할 수 있습니다. 매개 변수화 된 쿼리를 사용하십시오. – chris85
잘 작동합니다. 뭔가 다른 것이 분명합니다. 두 파일을 모두 저장했는데'장바구니에 담기 '링크를 클릭하면'cart.php'가 나에게'abc'를 보냅니다. – junkfoodjunkie
http://stackoverflow.com/help/someone-answers – RiggsFolly