這是我的HTML
<form class="login-form" method="POST">
<input type="password" placeholder="password" id="password" name="password"/>
<input type="button" id="login" name="login" value="login" onclick="redirect()"></input>
</form>
而我的JS
<script type="text/javascript">
$(document).ready(function redirect(){
$("#login").click(function(){
var pwd="<?php echo $pwd?>";
alert("<?php echo "this is pass".$pword?>");
if(userID===user && pwd===pass)
{
window.location.href = 'http://localhost/Annapoorna/Welcome_Page.php';
}
else
{
alert("Please enter correct username and password!");
}
}
});
});
</script>
和PHP
<?php
$username="";
$pwd="";
$pword="";
function confirm(){
if(isset($_REQUEST['password']))
{
$pword = $_REQUEST['password'];
}
$sth->execute(array(':pass'=>$pword));
foreach ($sth->fetchAll() as $row) {
$username=$row['username'];
$pwd=$row['password'];
echo $pword;
}
?>
$ _ POST沒有返回任何值。已嘗試$ _REQUEST,但沒有工作。已將ID和名稱分配給密碼字段。
'window.location.href ='http://localhost/Annapoorna/Welcome_Page.php';'參數在哪裏?提交表單或將參數添加到URL。不只是重定向 – Thamilan
嘿,頁面打開。所以沒有錯。 –
頁面將打開,參數在哪裏?你沒有通過那些 – Thamilan