php修改数据库出现问题

php中文网
发布: 2016-06-20 12:53:44
原创
979人浏览过

<form action="guanli_ok.php" method="post" enctype="multipart/form-data" name="form2" id="form2">      <table width="527" height="282" border="0" cellpadding="0" cellspacing="0">        <tr>          <td width="194" height="46"><div align="left"><?php echo $_SESSION['user'];?> 用户信息修改</div></td>          <td width="333"><div align="left"></div></td>        </tr>         <tr>          <td height="46"><div align="right">用户名:</div></td>          <td><div align="left"><input type="text" id="user" readonly="readonly" value="<?php echo $_SESSION['user'];?>"/></div></td>        </tr>        <tr>          <td height="40"><div align="right">原密码:</div></td>          <td><div align="left"><input type="text" id="pwd" /></div></td>        </tr>        <tr>          <td height="30"><div align="right">新密码:</div></td>          <td><div align="left"><input type="text" id="xpwd" /></div></td>        </tr>        <tr>          <td height="30"><div align="right">确认密码:</div></td>          <td><div align="left"><input type="text" id="quren" /></div></td>        </tr>        <tr>          <td height="30"><div align="right">部门:</div></td>          <td><div align="left"><input type="text" id="section" /></div></td>        </tr>        <tr>          <td height="30"><div align="right">真实姓名:</div></td>          <td><div align="left"><input type="text" id="name" /></div></td>        </tr>        <tr>          <td height="30"> </td>          <td><input type="submit" id="xiugai" value="确认修改"/> </td>        </tr>      </table>    </form>
登录后复制


这个是guanli_ok.php
<?php header("content-type:text/html;charset=utf-8");		//设置文件编码include("conn/conn.php");							//包含数据库连接文件if(isset($_POST['Submit']) and $_POST['Submit']=="提交"){		//判断提交按钮是否存在	$user=$_POST['user'];	        //定义用户名变量	$pwd=$_POST['pwd'];				//定义原密码变量	$xpwd=$_POST['xpwd'];					//定义新密码	$section=$_POST['section'];			//定义定义部门	$name=$_POST['name'];				//定义真实姓名	$insert=mysql_query("update tb_book set pwd='$xpwd',section='$section',name='$section' where id='$user' pwd='pwd'",$conn);		//执行更新操作	echo mysql_error();	if($insert){							//判断更新语句是否执行成功		echo "<script>alert('修改成功!');window.location.href='index.php'</script>";			//输出更新成功提示	}	else{		echo "<script>alert('修改失败!');window.location.href='insert.php'</script>";		//输出更新失败提示	}}?>
登录后复制

点击提交后调到guanli_ok.php  但是那边空白一片 也不会提示修改成功或者失败  是什么原因啊。。求解决方案

 4.9.8 英文版WordPress
4.9.8 英文版WordPress

WordPress是一种使用PHP语言开发的免费开源博客平台,用户可以在支持PHP和MySQL数据库的服务器上架设自己的站点,也可以把WordPress当作一个内容管理系统(CMS)使用。 WordPress 4.9.8 英文版 更新日志:2018-08-03 修复了46处bug、改进,包括自带的2017主题;最大的亮点是「呼吁」用户使用古腾堡编辑器。

 4.9.8 英文版WordPress 130
查看详情  4.9.8 英文版WordPress

回复讨论(解决方案)

SQL 串写错了
$insert=mysql_query("update tb_book set pwd='$xpwd',section='$section',name='$section' where id='$user'  AND pwd='pwd'",$conn); 

改了之后还是没反应,,,

SQL 串写错了
$insert=mysql_query("update tb_book set pwd='$xpwd',section='$section',name='$section' where id='$user'  AND pwd='pwd'",$conn); 

还是没反应啊。。

请你打开 php 的错误显示功能

请你打开 php 的错误显示功能

开启了  但是还是空白一片

 
if(isset($_POST['Submit']) and $_POST['Submit']=="提交"){ 不用解释了吧。。。

 
if(isset($_POST['Submit']) and $_POST['Submit']=="提交"){ 不用解释了吧。。。 已改  但是还是空白。,。


 
if(isset($_POST['Submit']) and $_POST['Submit']=="提交"){ 不用解释了吧。。。 已改  但是还是空白。,。
你没进if 

if(isset($_POST['xiugai']) and $_POST['Submit']=="确认修改"){ 

          <p class="yy">                  <p class="yy">     <p class="yy">      <td><input type="submit" id="xiugai" value="确认修改"/> </td> if(isset($_POST['Submit']) and $_POST['Submit']=="提交"){ 不用解释了吧。。。     </p>已改  但是还是空白。,。    </p> 你没进if   if(isset($_POST['xiugai']) and $_POST['xiugai']=="确认修改"){              </p> ...
登录后复制

php.ini 中
display_errors = On
重启 web 服务器

你的错误实际产生于 conn/conn.php

如果你的错误显示是打开的话
$insert=mysql_query("update tb_book set pwd='$xpwd',section='$section',name='$section' where id='$user' pwd='pwd'",$conn);        //执行更新操作
echo mysql_error(); //这里一定是有输出的,因为 sql 指令错了

conn

<?php$conn=mysql_connect("localhost","root","");			//连接数据库服务器mysql_select_db("db_book",$conn);						//连接数据库mysql_query("set names utf8");							//对数据库中编码格式进行转换,避免出现中文乱码的问题?>
登录后复制


错误

Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. 

If you think this is a server error, please contact the webmaster. 

Error 404
localhost
06/30/15 13:38:48
Apache/2.2.9 (APMServ) mod_ssl/2.2.9 OpenSSL/0.9.8h PHP/5.2.6 

Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. 

If you think this is a server error, please contact the webmaster. 

Error 404
localhost
06/30/15 13:38:48
Apache/2.2.9 (APMServ) mod_ssl/2.2.9 OpenSSL/0.9.8h PHP/5.2.6 




你开始说是guanli_ok.php  你截图是guanl_ok.php  


Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. 

If you think this is a server error, please contact the webmaster. 

Error 404
localhost
06/30/15 13:38:48
Apache/2.2.9 (APMServ) mod_ssl/2.2.9 OpenSSL/0.9.8h PHP/5.2.6 




你开始说是guanli_ok.php  你截图是guanl_ok.php   我改了   打开发现是空白的。。


Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. 

If you think this is a server error, please contact the webmaster. 

Error 404
localhost
06/30/15 13:38:48
Apache/2.2.9 (APMServ) mod_ssl/2.2.9 OpenSSL/0.9.8h PHP/5.2.6 




你开始说是guanli_ok.php  你截图是guanl_ok.php   没有错误提示

php.ini 中
display_errors = On
重启 web 服务器

你的错误实际产生于 conn/conn.php

如果你的错误显示是打开的话
$insert=mysql_query("update tb_book set pwd='$xpwd',section='$section',name='$section' where id='$user' pwd='pwd'",$conn);        //执行更新操作
echo mysql_error(); //这里一定是有输出的,因为 sql 指令错了

是我conn错了吗?

print_r($_POST); 就能发现是个空数组,怎么都不可能进入if里面。肯定为空了。

把你的form 定义改一改。
给 每个元素加上name 属性。


submit 也是一样,value改成value="提交"


改成


应该就能进入if分支了



Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. 

If you think this is a server error, please contact the webmaster. 

Error 404
localhost
06/30/15 13:38:48
Apache/2.2.9 (APMServ) mod_ssl/2.2.9 OpenSSL/0.9.8h PHP/5.2.6 




你开始说是guanli_ok.php  你截图是guanl_ok.php   没有错误提示

你打开一个不存在的页面  当然是报404了。。。   
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号