Notice: Undefined index: user in D:\phpStudy\WWW\js\ls\lsmc\php\add.php on line 9
2017-09-27 14:06
537 查看
(初用数据库(mysql)做用户登录注册这一块,遇到很多问题,通过搜索找到解决方案,把问题分享出来,希望可以帮助到和我一样问题的博友们,有问题还望多多指教。)
解决方法:在add.php文件最上边加上 error_reporting(E_ALL ^ E_NOTICE);
<?php
error_reporting(E_ALL ^ E_NOTICE);
require 'config.php'; //加载config.php
//新增用户
$query = "INSERT INTO lsmc_user(user,pass,yzm) VALUES ('{$_POST['user']}',sha1('{$_POST['pass']}'))";
mysql_query($query) or die('新增失败:'.mysql_error());
echo mysql_affected_rows(); //返回当前影响几行
mysql_close(); //关闭数据库
?>
解决方法:在add.php文件最上边加上 error_reporting(E_ALL ^ E_NOTICE);
<?php
error_reporting(E_ALL ^ E_NOTICE);
require 'config.php'; //加载config.php
//新增用户
$query = "INSERT INTO lsmc_user(user,pass,yzm) VALUES ('{$_POST['user']}',sha1('{$_POST['pass']}'))";
mysql_query($query) or die('新增失败:'.mysql_error());
echo mysql_affected_rows(); //返回当前影响几行
mysql_close(); //关闭数据库
?>
相关文章推荐
- 如何解决 Notice: Undefined index: submit in D:\wamp\www\bbs\add.php on line 9
- 表单中PHP的错误提示:Notice: Undefined index: submit in D:\wamp\www\bbs\add.php on line 4
- Undefined index: user in E:\wamp\wamp\www\liuyanbanban\login.php on line 4
- Notice: Undefined index: id in E:\wamp\wamp\www\liuyanbanban\modify.php on line 问题
- Testlink安装:Notice:Undefined index: type in C:\inetpub\wwwroot\testlink-1.9.3\install\installCheck.php on line 41
- Notice: Use of undefined constant out - assumed 'out' in D:wampwwwdaoruindex.php on line 4解决办法
- 为什么会出现Notice: Undefined index: submit in D:\xampp\htdocs\test.php on line 19
- Parse error: syntax error, unexpected '[' in D:\phpStudy\WWW\xxxxxxx\xxxxx\xxx.php on line 21问题
- ajax中url提交参数Undefined index: q in D:\xampp\htdocs\ajax.php on line 39
- PHP Notice: A session had already been started – ignoring session_start() in .. on line ..
- PHP Deprecated: Function split() is deprecated in /var/www/html/cacti/cmd.php on line 61
- Fatal error: Call to undefined function ParCv() in E:\AppServ\www\include\dedesql.class.php on line
- Deprecated: Call-time pass-by-reference has been deprecated in E:\wamp\www\admin\htdocs\busi.php on line 381
- Fatal error: Call to undefined function: get_headers() in /var/www/html/t.php on line 5
- Parse error: syntax error, unexpected $end in D:\webserver\www\test\test.php on line 27
- Notice: unserialize(): Error at offset 134526789 of 2136547489 bytes in file.php on line 130
- PHP中Notice: unserialize(): Error at offset 109 of 615 bytes in on line 的解决方法
- Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in E:\\PHP\\wamp\\www\\lsr\\lsr.php on line 42
- D:\phpStudya\WWW\bick\thinkphp\library\think\Loader.php on line 18
- Warning: require(D:\wamp\www\glink-smart\bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in D:\wamp\www\glink-smart\bootstrap\autoload.php on line 1