/    Sign up×
Community /Pin to ProfileBookmark

I have private messaging set up on my forum –

I can get the message to delete when you attempt to load that page, but I don’t want this – i want a button that you click that will delete that message, anyone know how this is done?

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@scragarFeb 04.2005 — [code=php]
<?
if(isset($_GET['del'])){//they want to delete.
$sql = "DELETE FROM pms WHERE To = ".$User." AND ID = ".$_GET['del'];
mysql_query($sql);
};[/code]
Copy linkTweet thisAlerts:
@kevinmcqueenauthorFeb 04.2005 — that go in an onclick event by any chance?

or a form?
Copy linkTweet thisAlerts:
@scragarFeb 04.2005 — you could create a form if you wanted:

[code=php]
<form action=? method=post>
<input type=checkbox name="PMS[]" value=1><br>
<input type=checkbox name="PMS[]" value=2><br>
<input type=checkbox name="PMS[]" value=3><br>
<input type=checkbox name="PMS[]" value=4><br>
<input type=checkbox name="PMS[]" value=5><br>
<input type=submit name="Sub" value="Delete">
</form>
[/code]


or a link:

[code=php]<?
if(isset($_GET['del'])){//they want to delete.
$sql = "DELETE FROM pms WHERE To = ".$User." AND ID = ".$_GET['del'];
mysql_query($sql);
};

?>

<a href="?del=<? echo $CurrPM ?>">Delete this PM</a>[/code]
Copy linkTweet thisAlerts:
@kevinmcqueenauthorFeb 04.2005 — that deletes the PM, but deletes it when the page loads, rather than when the link is clicked
Copy linkTweet thisAlerts:
@MstrBobFeb 05.2005 — [font=trebuchet ms][COLOR=royalblue]But you are passing a get variable. It won't delete the PM unless that variable is called, and that's how most systems do it. If you're looking to avoid refreshing the page, you can use Javascript to call a PHP page, but that's unneccessary, I feel, unless you've a real good reason to do so. So, you can have pm.php load, but if they click a link to pm.php?del, then it will delete the PM, should work just fine. The alternative, if you insist, would be to have a form POST the information, and check to see if the POST data is available, and if it is, delete the PM.[/COLOR][/font]
Copy linkTweet thisAlerts:
@JonaFeb 05.2005 — [font=trebuchet ms]He seems to be looking for a JavaScript method to delete a PM automatically. This cannot be done without an XMLHttpRequest (which does not work in all browsers). Your best and most accessible way would be to use PHP exclusively. You will always have to reload the page for PHP to get the query - you can't use JavaScript to delete a PM without reloading the page. Well, you can in theory, but I for one wouldn't do that for anyone -- not for free. I would consider other options.[/font]
Copy linkTweet thisAlerts:
@kevinmcqueenauthorFeb 05.2005 — thanks all...

i had the delete button inside the actual PM, rather than the index page for the PMs.

This was causing it to delete when I opened up the PM, even if i did not want it to.

Sorted now. Thanks again :-)
×

Success!

Help @kevinmcqueen spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...