I have the following bit of code:
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;
}
}
A few questions.
- How do I set
$passwordequal to theusernamevariable passed into the function? - Why don't I get the
confirm()dialog when I call the function?