ajaxpost方法与php
总而言之,我在这里解释我的问题(据我所知,我没有找到任何有效的解决办法)。 我在这里链接我的文件: progetto.htmlajaxpost方法与php,php,ajax,post,login,Php,Ajax,Post,Login,总而言之,我在这里解释我的问题(据我所知,我没有找到任何有效的解决办法)。 我在这里链接我的文件: progetto.html <html> <head> <script type="text/javascript" src="funzioni.js"></script> <title>Pagina iniziale</title> </head> <body align='center
<html>
<head>
<script type="text/javascript" src="funzioni.js"></script>
<title>Pagina iniziale</title>
</head>
<body align='center'>
<p>Gymnasium</p>
<p>icona</p>
<form id="ajaxForm" name="ajaxForm">
<table align="center">
<tr>
<td><label>Utente</label></td>
<td><input type="text" name="user" id="user" value="" /></td>
</tr>
<tr>
<td><label>Password</label></td>
<td><input type="password" name="password" id="password" value="" /></td>
</tr>
</table>
<input type="button" id="submit" name="submit" value="Accedi" onclick='submitForm()' />
</form>
<div id="risultato"></div>
</body>
}
}
ajaxLogin.php
<?php
if (!isset($_POST["user"]) || !isset($_POST["password"])){
die("Bad login");
}
$user = $_POST['user'];
$pwd = $_POST['password'];
if ( (($user == "angel") && ($pwd == "devil")) || (($user == "john") && ($pwd == "smith")) ){
$response = "Benvenuto " . $user;
echo $response;
}
问题是我总是收到错误的登录消息,即使我使用了正确的用户和密码。
这是一个POST问题,我真的很难想出解决方案 这是您的数据:
var data = "utente=" + document.getElementById('user').value + "&password=" + document.getElementById('password').value;
这就是您要检查的内容:
if (!isset($_POST["user"]) || !isset($_POST["password"])){
您应该将utete
更改为user
,或者相反。在您的表单中,您也在使用user
,因此我建议您在任何地方都使用它
因此:
@用户3184908不客气,如果解决了您的问题,请不要忘记将答案标记为已接受。
var data = "utente=" + document.getElementById('user').value + "&password=" + document.getElementById('password').value;
if (!isset($_POST["user"]) || !isset($_POST["password"])){
var data = "user=" + document.getElementById('user').value + "&password=" + document.getElementById('password').value;