我一直在試圖切換到準備好的語句,但我無法弄清楚爲什麼我的新代碼不再起作用。我對使用這些軟件仍然陌生,但仍然知道這是安全的最佳實踐。任何幫助,將不勝感激。謝謝。準備好的語句不運行MYSQLI PHP
<?php
$servername = "11.11.11.11";
$username = "root";
$password = "root";
$dbname = "sit";
$conn = new mysqli($servername, $username, $password,$dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
$result = mysqli_query($conn, "SELECT * FROM `ourstory` ");
$values = mysqli_fetch_array($result);
if(isset($_POST['ourstory_title'])){
$ourstory_title = $_POST['ourstory_title'];
$ourstory_testimonial = $_POST['ourstory_testimonial'];
$ourstory_content = $_POST['ourstory_content'];
$ourstory->execute();
$ourstory = $conn->prepare("UPDATE ourstory SET
ourstory_title='$ourstory_title' ,
ourstory_content='$ourstory_content' ,
ourstory_testimonial='$ourstory_testimonial'
WHERE ourstory_id='1'");
$ourstory->bind_param("sss", $ourstory_title, $ourstory_content, $ourstory_testimonial);
if (mysqli_query($conn, $ourstory)) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($conn);
}
$ourstory->close();
$conn->close();
}
?>
<form id="comment_form" method="post"
action="<?php echo $ourstory?>"
onsubmit="setTimeout(function() {
window.location.reload();
}, 10), location.reload(true);">
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="85%">About Us Title</td>
</tr>
<tr>
<td>
<input class="commentarea"
name="ourstory_title" type="text"
id="ourstory_title" value="<?php echo $values['ourstory_title']?>">
</td>
</tr>
<tr>
<td width="85%" >Testimonial</td>
</tr>
<tr>
<td>
<pre>
<textarea class="commentarea"
name="ourstory_testimonial" type="text"
id="ourstory_testimonial" rows= "10" ><?php echo $values['ourstory_testimonial']?>
</textarea>
</pre>
</td>
</tr>
<tr>
<td width="85%" >About Us Content</td>
</tr>
<tr>
<td>
<pre>
<textarea class="commentarea" name="ourstory_content"
type="text" id="ourstory_content"
rows= "10" ><?php echo $values['ourstory_content']?>
</textarea>
</pre>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Update">
</td>
</tr>
</table>
</form>
讓我們[繼續聊天討論](HTTP://聊天.stackoverflow.com /房間/ 81295 /討論-之間-fred的-II和 - 肖恩 - 迪瓦恩)。 –