ニュースサイトの編集ボタンで問題が発生しています...どんな種類のヘルプも大歓迎です...これが私のコードです..無関係なコードは無視します
admin_first.php
<?php
$connection = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_BASE);
$query = "SELECT * FROM news ORDER BY id";
$result = mysqli_query($connection, $query);
while($row = mysqli_fetch_array($result))
{
$id[] = (int) $row['id'];
$header[] = htmlspecialchars($row['header']);
$text[] = htmlspecialchars($row['text']);
$picture[] = htmlspecialchars($row['pictures']);
$date[] = $row['time'];
}
if(mysqli_num_rows($result) != 0)
{
for($i=0; $i<count($id); $i++)
{
echo '<div class="new_item"><h2>' . $header[$i] . '</h2><p class="text">' . $text[$i] . '</p><a href="' . $picture[$i] . '" target="_blank"><img src="' . $picture[$i] . '"/></a><p class="time">' . $date[$i] . '</p></div>
<div class="buttons"><form><input type="button" name="delete" id="delete" onclick="window.location.href=\'process_buttons.php?delete=' . $id[$i] . '\'"
value="Obri�i vest"/><input type="button" name="edit" id="edit" onclick="window.location.href=\'process_buttons.php?edit=' . $id[$i] . '\'" value="Izmeni vest"/></form></div>';
}
}
mysqli_close($connection);
?>
そしてここにある
process_buttons.php
<?php
include 'functions.php';
include 'constants.php';
is_logged_in("admin.php");
$connection = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_BASE);
$safe_id = filter_input(INPUT_GET, 'delete', FILTER_SANITIZE_STRING);
if(!empty($_GET['delete']))
{
$query = "DELETE FROM news WHERE id='{$safe_id}'";
$result = mysqli_query($connection, $query) or die(mysqli_error());
header("Location: admin_first.php");
}
else
{
?>
これは削除部分です。正常に動作しています。
問題はこの部分にあります:
<?php
$safe_id = (int) $_GET['edit'];
$query = "SELECT * FROM news WHERE id='{$safe_id}'";
$result = mysqli_query($connection, $query);
while($row = mysqli_fetch_array($result))
{
$header = htmlspecialchars($row['header']);
$text = nl2br(htmlspecialchars($row['text']));
$picture = $row['picture'];
header("Location: admin_first.php");
}
?>
前もって感謝します...