【发布时间】:2018-03-17 20:29:59
【问题描述】:
运行此代码时,我不断收到“注意:未定义索引:用户名”。
注意:未定义索引:用户名在 /public_html/handler.php 上线 7
注意:未定义索引:密码在 /public_html/handler.php 上线 8
注意:未定义索引:第 9 行 /public_html/handler.php 中的 hwid
<?php
include('db.php');
$action = $_GET['action'];
$username = $con->real_escape_string($_GET['username']);
$password = $con->real_escape_string(md5(md5(md5($_GET['password']))));
$hwid = $con->real_escape_string($_GET['hwid']);
$invite_code = $con->real_escape_string($_GET['invite_code']);
$logged = false;
if(!$action)
{
echo "Error";
}
else
{
if($action == "register_admin_xd")
{
if($query = $con->query("INSERT INTO users (username,password) VALUES
('$username','$password')"))
{
echo "1";
}
else
{
echo "0";
}
}
这里是 db.php
$host = "dbhostname";
$user = "dbusername";
$pass = "dbpassword";
$data = "database";
$con = new mysqli($host, $user, $pass, $data);
if($con->connect_errno)
{
printf("Connect failed: %s\n", $con->connect_error);
}
【问题讨论】:
-
这些变量的 url 是否传递值??
-
在脚本的第一行使用
echo "<pre>"; print_r($_GET);并分享打印在屏幕上的结果 -
@ParitoshMahale 我得到 Array ([action] => login3 [invite_code] => 1)
-
@jophab 我正在使用这个 php 从我的数据库中提取数据
标签: php sql undefined isset undefined-index