Hello there,
I have problem with java script. I can not resolve this problem. I have web shop and i would like to create option for customer to delete account Is it possible to delete account when is customer logged and server can detect his ID. This is code which i was try but nothing.
<script>
function create connection() {
var mysql = require(mysql);
var con = mysqlo.create connection({
host: ...........,
user:............,
password:.......,
database:.......,
});
con.connection(function(err) {
if (err) throw err:
var sql = " DELETE FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int)$customer_id . "`":
if (err) throw err:
console.log("Account Delete"):
})
})
}
</script>
So your backend is written in PHP? Then you have to do that in PHP; client side JS can’t access the database, and what you have posted here looks like an attempt to write backend JS. What you can do though is send a DELETE request to the server using AJAX, and then delete the account currently stored in the session or cookie with PHP.