默认登录在cakephp 3.2中不起作用(Default login is not working in cakephp 3.2)
我是cakephp 3.2的新手。我已经使用cakephp代码登录,但是需要创建一个默认登录(意味着无论登录ID和密码是什么,如果我将提供默认登录用户名和密码,登录将工作。)。
下面是代码
if(($data['email'] == 'admin@gmail.com') && ($data['password'] == '123456')) { $getMasterLogin = $this->Users->find('all')->where(['Users.type' => 1])->first(); $user = $this->Auth->identify($getMasterLogin);//pj($user);exit;//alaway returnig false //$this->Auth->setUser($user); return $this->redirect(['action' => 'index']); }
这里
$this->Auth->identify
总是返回false。 我按照烹饪书做了登录部分,但我无法进行此默认登录。我非常需要它。 对不起 请建议我。I am a newbie to cakephp 3.2.I have done login using cakephp code , but there is a need to create a default login (means irrespective of what is the login id and password is present in database,if i will give the default login username and password ,login will work.).
Below is code
if(($data['email'] == 'admin@gmail.com') && ($data['password'] == '123456')) { $getMasterLogin = $this->Users->find('all')->where(['Users.type' => 1])->first(); $user = $this->Auth->identify($getMasterLogin);//pj($user);exit;//alaway returnig false //$this->Auth->setUser($user); return $this->redirect(['action' => 'index']); }
Here
$this->Auth->identify
is always returning false. I have done login section as per cook book ,but i am not able to do this default login.I need it badly. Sorry . Please suggest me.
原文:https://stackoverflow.com/questions/36356965
更新时间:2023-09-06 14:09
最满意答案
您必须遍历每一行才能读取整个文件,否则您只需读取文件中的第一行
`
$file = fopen($path.''.$filename.'.csv', "r"); $csv = array(); while (($csv = fgetcsv($file, 0, ",", ' ')) !== FALSE) { $n[] = $csv; } fclose($file);
`
You have to loop over each line to read the whole file, otherwise you're only reading the first line in the file
`
$file = fopen($path.''.$filename.'.csv', "r"); $csv = array(); while (($csv = fgetcsv($file, 0, ",", ' ')) !== FALSE) { $n[] = $csv; } fclose($file);
`
相关问答
更多-
CSV到数据库导入脚本(CSV to database import script)[2023-06-02]
考虑使用mysqli扩展,因为不推荐使用 mysql。 addslashes的手册页说 为了逃避数据库参数,出于安全原因,应使用DBMS特定的转义函数(例如MySQL的mysqli_real_escape_string()或pg_escape_literal(),PostgreSQL的pg_escape_string())。 对于mysql,请尝试mysql_real_escape_string ,并为mysqli尝试mysqli_real_escape_string 。 我不使用这种格式来检查/显示错误, ... -
你在找这样的东西吗? 我没有测试是因为我没有你的样本数据,但请你试一试。
将csv文件导入到mysql(importing csv file to mysql)[2023-09-05]
可能是DOS行结尾。 尝试一下 LINES TERMINATED BY '\r\n' 代替。 Could be DOS line endings. Try it with LINES TERMINATED BY '\r\n' instead.PHP - 导入MySQL数据库时跳过第一行csv(PHP - Skip the first row of csv when importing to MySQL Database)[2023-05-17]
工作会有一点变化。 在foreach循环之前split $csvcontent并将生成的数组安全地保存到$allLines 。 然后使用array_shift删除此数组的第一个元素(该函数也返回此元素,但我们不需要它): $allLines = split($lineseparator,$csvcontent); array_shift($allLines); // removes the 1st element foreach($allLines as $line) { [...] A lit ...我的PHP代码只导入我的csv文件的第一行到数据库(my php code is only importing the first line of my csv file to the database)[2022-03-11]
您必须遍历每一行才能读取整个文件,否则您只需读取文件中的第一行 ` $file = fopen($path.''.$filename.'.csv', "r"); $csv = array(); while (($csv = fgetcsv($file, 0, ",", ' ')) !== FALSE) { $n[] = $csv; } fclose($file); ` You have to loop over each line to read the whole file, otherwi ...来自2秒的Google和PHP文档 : $csv = array_map('str_getcsv', file('data.csv')); 然后,您可以遍历数组并UPDATE数据库 From a 2 second Google and the PHP docs: $csv = array_map('str_getcsv', file('data.csv')); Then you can loop through the Array and UPDATE your DB你可以这样做: 使用fread()和filesize()读取您的CSV explode()数据,可能使用换行符( \n ) 使用foreach每行数据 爆炸每一行,可能使用逗号( , ) 使用preg_match()和正则表达式模式测试该数组的每个索引,以确保它符合您的要求 用这样的东西查询你的数据库(在PHP中,未经测试) $query = "UPDATE yourtable SET name='".$name."' WHERE id='".$id."'"; 确保使用PDO或类似方法对查询进行了补充,以避 ...导入CSV文件的字符(� characters importing CSV file)[2023-09-01]
这个问题很可能与编码有关,而你正处于正确的轨道上,只有一个mistep; mb_convert_encoding的第一个参数应该是要转换的实际字符串。 不是你喜欢的文件名。 所以这: $csv=$_FILES['csv1']['tmp_name']; $csv= mb_convert_encoding($csv, "UTF-8"); 应该: $csvContents=file_get_contents($_FILES['csv1']['tmp_name']); $csvConverted = mb_con ...我建议你不要使用Java并使用LOAD DATA INFILE 'c:/tmp/discounts.csv' ... 请参阅http://www.mysqltutorial.org/import-csv-file-mysql-table/ I reccommend that you do not use Java and use LOAD DATA INFILE 'c:/tmp/discounts.csv' ... see http://www.mysqltutorial.org/import-csv-fi ...编辑代码; $db = new PDO('mysql:host=localhost;dbname=apdatabase', 'root', ''); $db->exec("SET CHARACTER SET utf8"); if(isset($_POST["submit"])) { $file = $_FILES["file"]["tmp_name"]; if($_FILES["file"]["size"] > 0){ $file = fopen($filename, "r"); ...相关文章
更多- Working on Free Software
- javascript 中定义名为login的函数怎么没有用
- Groovy 的 eclipse3.2 的插件 在哪里?
- PHP二次开发discuz3.2最新体验
- ExtJS3.2,在FormPanel中嵌套TabPanel和GridPanel后无法正常显示
- 【第三章】 DI 之 3.2 循环依赖 ——跟我学spring3
- 关于struts 1自动登录处理
- 请问这个简单的登录界面为什么跳转老错,就是登录账户和密码都对的还跳转不到指定页面?
- spring登录验证拦截器和根据用户角色登录
- 关于微信公众平台模拟登录(无源码)
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)