Aşağıda gösterilen aşağıdaki kodum var. Benim sorunum şu anda bu mysql tablosunun her kaydı güncellenmesine izin veriyor. Olmak istediğim, kullanıcının güncelleme düğmesine tıklaması ve bu kaydı orijinal forma çeken bir kod parçasını çalıştırmasıdır. Böylece sadece bir rekoru güncelleyebilirler. ÖncedenGüncelleme mysql'nin tek tek kayıtları
Sen girdi etiketleri kapatmak için cevapsız<html>
<head>
<title>Comic Collectors Club</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" media="screen and (min-width:481px)">
<link rel="stylesheet" type="text/css" href="stylesheet mobile.css" media="screen and (max-width:480px)">
</head>
<body>
<div id="page">
<div id="header">
<h1>Welcome To The Comic Collectors Club Website</h1>
</div>
<div id="nav">
</body>
<ul class="nav navbar-nav">
<li><a href="index.html">Home</a></li>
<li><a href="#">About Us</a></li>
<li><a href="database.html">Add Your Comic To The Database</a></li>
<li><a href="export.php">View Our Collection</a></li>
<li><a class="active" href="update.php">Update Our Collection</a></li>
</ul>
</div>
<div id="section">
<div id="search">
<input type="text"></input>
<input type="button" value="Search"></input>
</div>
<h1>Update Our Collection</h1>
<?php
define('DB_NAME', 'comics');
define('DB_USER', 'root');
define('DB_PASSWORD', 'password1234');
define('DB_HOST', 'localhost');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$link) {
die("Could not connect: " . mysql_error());
}
mysql_select_db("comics",$link);
if (isset($_POST['update'])){
$UpdateQuery = "UPDATE comics SET Email='$_POST[email]', Title='$_POST[Title]', Issue='$_POST[issue]', Edition='$_POST[edition]', Publisher='$_POST[publisher]', Quality='$_POST[quality]' WHERE Email='$_POST[hidden]'";
mysql_query($UpdateQuery, $link);
};
$sql = "SELECT * FROM comics";
$myData = mysql_query($sql,$link);
echo "<table border=1>
<tr><th>Email</th>
<th>Title</th>
<th>Issue</th>
<th>Edition</th>
<th>Publisher</th>
<th>Quality</th>
<th>Cover Image</th></tr>";
while($record = mysql_fetch_array($myData)){
echo "<form action=update.php method=post>";
echo "<tr>";
echo "<td>" . "<input type=email name=email value=" . $record['Email'] . " </td>";
echo "<td>" . "<input type=text name=title value=" . $record['Title'] . " </td>";
echo "<td>" . "<input type=number name=issue value=" . $record['Issue'] . " </td>";
echo "<td>" . "<input type=text name=edition value=" . $record['Edition'] . " </td>";
echo "<td>" . "<input type=text name=publisher value=" . $record['Publisher'] . " </td>";
echo "<td>" . "<input type=text name=quality value=" . $record['Quality'] . " </td>";
echo "<td>" . "<input type=hidden name=hidden value=" . $record['Email'] . " </td>";
echo "<td>" . "<input type=submit name=update value=update" . " </td>";
echo "</form>";
}
echo "</table>";
mysql_close($link);
?>
<div id="footer">
<table width="100%">
<tr>
<td><a href="#">Company Information</a></td>
<td><a href="#">Conventions</a></td>
<td><a href="#">Collections</a></td>
<td><a href="#">Your Account</a></td>
</tr>
</table>
</div>
</div>
</body>
</html>
Burada bir SQL enjeksiyona açıksınız, btw. –
Bir sınıf projesi için, ancak daha güvenli hale getirmek için önerilere açığım. Herhangi bir öğrenme iyi öğreniyor – Spencer