我不明白我在哪里';在这个php代码中,对用户进行身份验证是错误的
这是php代码:我不明白我在哪里';在这个php代码中,对用户进行身份验证是错误的,php,authentication,Php,Authentication,这是php代码: <?php if(isset($_POST['submit']) && (trim($_POST['submit']) == "Login")){ if( !isset($_POST['username']) || $_POST['username']=="" ){ echo "Attenzione, inserire l' username."; }else{ require_once("dbConnection.php"
<?php
if(isset($_POST['submit']) && (trim($_POST['submit']) == "Login")){
if( !isset($_POST['username']) || $_POST['username']=="" ){
echo "Attenzione, inserire l' username.";
}else{
require_once("dbConnection.php");
$db_handle = new DBConnection();
$query = "INSERT INTO studente (Nome, Cognome, Matricola, Username, Codice)
SELECT Nome, Cognome, Matricola, Username FROM studenti_in_sessione WHERE
studenti_in_sessione.Username = '" . $_POST["username"] . "'";
$result = $db_handle->insertQuery($query);
if(!empty($result)){
echo "
<script type=\"text/javascript\">
swal({
title: \'Mail inviata\',
text: \"Arriverà un codice all'indirizzo di posta elettronica istituzionale con le istruzioni per accedere.\",
type: \'success\',
}).then(function () {
document.getElementById(\"popup\").style.display = \"block\";
document.getElementById(\"view\").style.display = \"none\";
})
</script> " ;
}else{
echo "
<script type=\"text/javascript\">
swal({
title: \'Errore\',
text: \"Le credenziali sono sbagliate!\",
type: \'error\',
})
</script> ";
}
}
//$db_handle->disconnectDB();
}
?>
首先,快速查看您发布的用户名似乎为空。确保您具有html元素名称“username”。您忘记了表单中的名称属性
<input type="text" id="username" name="username">
Short版本:无处不在。基本上,每个代码包含一个问题或攻击向量。了解SQL注入。你的代码真的没有保存,你的数据库可以在几秒钟内被黑客入侵而不需要任何知识。你的表单输入没有名称属性每行代码都有太多问题
<input type="text" id="username" name="username">