Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
不知道我做错了什么php登录脚本_Php_Mysql_Login_Phpmyadmin - Fatal编程技术网

不知道我做错了什么php登录脚本

不知道我做错了什么php登录脚本,php,mysql,login,phpmyadmin,Php,Mysql,Login,Phpmyadmin,按照指示,我必须在虚线之间插入代码。 应该刷新并查看“存在” 我有正确的数据库,表格,一切我很确定,但是 我看不到存在。 我应该继续跟着导游走,还是我搞砸了 如果我正确地遵循指南,是否有人有保证有效的指南 我的login.php <?php include 'core/init.php'; ----------------------------------------- if (user_exists('alex') === true) { echo "exists"; } die('

按照指示,我必须在虚线之间插入代码。 应该刷新并查看“存在” 我有正确的数据库,表格,一切我很确定,但是 我看不到存在。 我应该继续跟着导游走,还是我搞砸了

如果我正确地遵循指南,是否有人有保证有效的指南

我的login.php

<?php
include 'core/init.php';

-----------------------------------------
if (user_exists('alex') === true) {
echo "exists";
}
die('no exist');
-------------------------------------------
if (empty($_POST) === false) {
    $username = $_POST['username'];
    $password = $_POST['password'];

    if (empty($username) === true || empty($password) === true) {
        $errors[] = 'You need to enter a username and password';
    } else if (user_exists($username) === false) {
        $errors[] = 'We can not find that user';
    }
}
    ?>

我有init.php

<?php
session_start();
error_reporting(0);

require 'database/connect.php';
require 'functions/general.php';
require 'functions/users.php';

$errors = array();
?>

我有users.php

<?php
function user_exists($username) {
    $username = sanitize($username);
    $query = mysql_query("SELECT COUNT('user_id') FROM 'users' WHERE 'username' = '$username'");
    return (mysql_result($query, 0) == 1) ? true : false;
}
?>

i have general.php
<?php
function sanitize($data) {
    return mysql_real_escape_string($data);
}
?>

始终调用您的
模具
,您应该将代码更改为:

if (user_exists('alex') === true) {
    echo "exists";
}
else{
   die('no exist');
}

你犯了什么错误?那为什么那家伙说我应该看到“存在”啊?这个问题和phpmyadmin有什么关系?您是否验证了您的
users
表中确实有一行用户名为
“alex”
?我相信代码只是用于测试的。当然,OP需要澄清。
if (user_exists('alex') === true) {
    echo "exists";
}
else{
   die('no exist');
}