Jul 20th 2016, 6:55:48
I read on one of the posts the ability to delete emails.
Can we just add a button and send a query string to db?
I'm not exactly sure how you have your DB setup,. but you could also you DELETE FROM.
The HYPHENED data will have to be replaced by real values.
Can we just add a button and send a query string to db?
<button onclick="deleteEmails()">Delete All Emails</button>
<script>
function deleteEmails() {
var ans = confirm("This will delete ALL emails!");
if (ans == true) {
ajax();
}
}
function ajax(){
var formData = {userID:"USER-ID-GOES-HERE",delete:"yes"};
$.ajax({
url : "PHP-FILE-HERE",
type: "POST",
data : formData,
success: function(data, textStatus, jqXHR)
{
//data - response from server
},
error: function (jqXHR, textStatus, errorThrown)
{
}
});
</script>
PHP-FILE-HERE
<?php
$userid = $_REQUEST['username'];
$ans = $_REQUEST['delete'];
if ($ans == 'yes'){
$sql = "UPDATE NAME-OF-TABLE-HERE SET msgs="" WHERE id=USER-ID-HERE";
$conn->query($sql);
}
I'm not exactly sure how you have your DB setup,. but you could also you DELETE FROM.
The HYPHENED data will have to be replaced by real values.
Edited By: Stryke on Jul 28th 2016, 19:05:03. Reason: Clarification.
Resistance is futile. You will be assimilated.