修改管理員,提示修改成功,但是數據庫中只修改了郵箱,用戶名和密碼都沒有修改
doAdminAction.php
<?php
require_once?'../include.php';
$act?=?$_REQUEST['act'];
$id?=?$_REQUEST['id'];
if?($act?==?"logout")?{
????logout();
}?elseif?($act?==?"addAdmin")?{
????$mes?=?addAdmin();
}elseif?($act?==?"editAdmin"){
????$mes=editAdmin($id);
}
?>function?editAdmin($id){
????$arr=$_POST;
????$arr['password']=md5($_POST['password']);
????print_r($arr);
????//$mes=update("shop_admin",?$arr,"id={$id}");
????if(update("shop_admin",?$arr,"id={$id}")){
????????$mes="編輯成功!<br/><a?href='listAdmin.php'>查看管理員列表</a>";
????}else{
????????$mes="編輯失敗!<br/><a?href='listAdmin.php'>重新修改</a>";
????}
????return?$mes;
}editAdmin.php
<?php?
????require_once?'../include.php';
????$id=$_REQUEST['id'];
????$sql="select?id,username,password,email?from?shop_admin?where?id='{$id}'";
????$row=fetchOne($sql);
????print_r($row);
?><!DOCTYPE?html?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN"?"http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta?http-equiv="Content-Type"?content="text/html;?charset=UTF-8"> <title>Insert?title?here</title> </head> <body> <form?action="doAdminAction.php?act=editAdmin&id=<?php?echo?$id;?>"?method="post"> <h3>編輯管理員</h3> ????<table?width="70%"?border="1"?cellpadding="5"?cellspacing="0"?bgcolor="#cccccc"> <tr> <td>管理員名稱</td> <td><input?type="text"?name="username"?placeholder="<?php?echo?$row['username'];?>"?/></td> </tr> <tr> <td>管理員密碼</td>
<td><input?type="password"?name="password"?value="<?php?echo?$row['password'];?>"/></td> </tr> <tr> <td>管理員郵箱</td> <td><input?type="text"?name="email"?placeholder="<?php?echo?$row['email'];?>"?/></td> </tr> <tr> <td?colspan="2"><input?type="submit"?value="編輯管理員"> </tr> </table> </form> </body> </html>
2017-04-17
?$where = $where == null ? null : " where ". $where;//" where處必須要有空格:" where ""
$str="";//必須在循環外
2017-04-19
我的解決了?? 我是查表數據里的參數寫錯了,查不到數據,后來改了就好了
2017-04-14
老哥,我為啥用老師的那個mysql下的update函數會報錯,提示$str事未定義的變量 啊,完全不能用,能給我看下你的update函數嘛