我有下面的代碼位:PHP裏面的Javascript?
function deletet(username){
if(confirm("Do you REALLY want to delete your account?")){
if(confirm("Are you POSITIVE?")){
var check = prompt("Enter your password","");
if(check){
<?php
require('functions.php');
mysqlLogin();
$password =
$username = $_COOKIE['sqlusername'];
$queyreg = ("SELECT * FROM `users` WHERE username='$username'");
$row = mysql_fetch_array($queryreg,MYSQL_ASSOC);
$hash = hash('sha256', $row['salt'] . hash('sha256', $password));
if($hash == $row['password']){
$sql = mysql_query("DELETE FROM `users` WHERE username='$username' AND password='$hash'");
if($sql){
?> alert("Account deleted, thank you"); window.location='login.php'; <?php
} else {
?> alert("There was an error deleting your account"); return false; <?php
}
} else {
?> alert("Passwords don't match!"); return false; <?php
}
?>
return true;
} else {
alert("Please enter your password!");
return false;
}
} else {
return false;
}
} else {
return false;
}
}
的幾個問題。
- 我該如何設置
$password
等於username
變量傳入函數? - 爲什麼我在調用函數時沒有得到
confirm()
對話框?
我建議你使用AJAX來做到這一點。 –
http://www.google.com/search?rlz=1C1CHKZ_enUS436US436&sourceid=chrome&ie=UTF-8&q=ajax – David