我正在尝试管理面板。我用PDO进行数据库连接。在面板中,我想更新网站标题,网站网址等。但我有一个问题。我确信我做的都是真的。
我需要你的帮助。
这是管理员代码:
<script>
var a = false;
function toggleBold(){
a = !a;
if(a){
document.getElementById("entertext").style.fontWeight=700;
}
else{
document.getElementById("entertext").style.fontWeight=200;
}
}
var b = false;
function toggleitalic(){
b = !b;
if(b){
document.getElementById("entertext").style.fontStyle="italic";
}
else {
document.getElementById("entertext").style.fontStyle="normal";
}
}
var c = false;
function toggleline() {
c =!c;
if(c){
document.getElementById("entertext").style.textDecoration="underline";
}
else {
document.getElementById("entertext").style.textDecoration="none";
}
}
var r = false;
function togglered() {
console.log("clicked");
r=!r;
if(r){
document.getElementById("entertext").style.color="red";
}
else{
document.getElementById("entertext").style.color="black";
}
}
var b = false;
function toggleblue() {
console.log("clicked");
b=!b;
if(b){
document.getElementById("entertext").style.color="blue";
}
else{
document.getElementById("entertext").style.color="black";
}
}
var g = false;
function togglegreen() {
g=!g;
if(g){
document.getElementById("entertext").style.color="green";
}
else{
document.getElementById("entertext").style.color="black";
}
}
var imp = false;
function togglefontA(){
imp = !imp;
if(imp){
document.getElementById("entertext").style.fontFamily= "Impact,Charcoal,sans-serif";
}
}
var tim = false;
function togglebfontB(){
tim=!tim;
if(tim){
document.getElementById("entertext").style.fontFamily = "Times New Roman, Times, serif";
}
}
var age = false;
function togglefontC(){
age=!age;
if(age){
document.getElementById("entertext").style.fontFamily = "Agency FB, verdana, helvetica, sans-serif";
}
}
var nor = false;
function togglefontD(){
nor=!nor;
if(nor){
document.getElementById("entertext").style.fontFamily = "Arial, Helvetica, sans-serif";
}
}
function rgb(){
if(check()){
document.getElementById("entertext").style.backgroundColor =
"rgb("+document.getElementById("red").value+","
+ document.getElementById("green").value+","
+ document.getElementById("blue").value+")";
}
else{
document.getElementById("entertext").style.backgroundColor = "white";
}
}
function check(){
var red= document.getElementById("red").value;
var green= document.getElementById("green").value;
var blue= document.getElementById("blue").value;
return red <= 255 && red >= 0 && green <= 255 && green >= 0 && blue <= 255 && blue >= 0;
}
</script>
这是islem.php:
<?php
include 'config.php';
$ayarsor=$db->prepare("select * from ayar1 where ayar_id=?");
$ayarsor->execute(array(0));
$ayarcek=$ayarsor->fetch(PDO::FETCH_ASSOC);
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<title></title>
</head>
<body>
<div class="ust">
<h1><center>panel</center></h1>
</div>
<div class="container">
<h2>Send something</h2>
<p> ADMİN PANELİ</p>
</div>
<div class="orta">
<table>
<form action="islem.php" method="POST">
<tr>
<td><label>Site başlığı</label></td>
<td><input type="text" name="ayar_title" /></td>
</tr>
<tr>
<td><label>Duyuru</label></td>
<td><input type="text" name="ayar_duyuru" value="<?php echo $ayarcek['ayar_duyuru']; ?>" /></td>
</tr>
<tr>
<td><label>Düşman</label></td>
<td><input type="text" name="ayar_dusman" /></td>
</tr>
<tr>
<td></td>
<td><button name="genelayarkaydet">Güncelle</button></td>
</tr>
</form>
</table>``
</div>
答案 0 :(得分:0)
您需要绑定数据库查询的变量。
$ayarkaydet = $db->prepare("UPDATE ayar1 set ayar_title = :sitetitle,
ayar_duyuru = :duyuru,
ayar_dusman = :dusman
WHERE ayar_id = 0");
$update = $ayarkaydet->execute(array(
'sitetitle' => $_POST['ayar_title'],
'duyuru' => $_POST['ayar_duyuru'],
'dusman' => $_POST['ayar_dusman']
));