这是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表单:
<form action="../Slide_upload/database/signIn.php" method="POST">
<label for="username">Username</label>
<br/>
<input type="text" id="username">
<input name="submit" type="submit" value="Login">
当文字是&#34;形式&#34;并且输入不为空总是返回警告消息 Form
我查看并覆盖了代码,因为我可能错误地编写了变量,显然它没有犯任何错误。
答案 0 :(得分:0)
从一开始,快速查看看起来你在用户名上的POST是空的。确保你有html元素名称'username'。
答案 1 :(得分:0)
您忘记了表单中的name
属性
<input type="text" id="username" name="username">