The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End I need help with PHP delete form confirmation! ASAP

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #30956

    Hello someone, or people.. lol

    Heres my problem, i’m trying to delete a record from my sql database that displays a confirmation message with a continue button. If they press continue, their “account” is deleted and they will be redirected to the login page. Now, i have the code working that removes the account from the database, and redirects them to the login page.

    Here is my code:
    $delete = $_GET;
    $confirmDel = ‘
    Are you sure you want to delete your account?

    $query = “DELETE FROM users
    WHERE username = ‘” . $username . “‘”;

    $rs = mysqli_query($oConn, $query);


    Here is my problem:

    As of where I stand at the moment, once i click the delete button, the confirmation message will be displayed along with the continue button. Although, all it does is refresh the doesn’t delete and redirect.

    Note: I’m a beginner at PHP and really not sure why this is happening and I dont know what to do. Your help would be greatly appreciated!


    I’m not entirely sure what you are doing here… As personal preference I would always have a JavaScript Confirm Delete box, but then also include a PHP delete to fall back on.

    Your $confirmDel isn’t actually being output to the page at any point, unless you are missing some code? You also seem to be getting mixed up with $_POST and $_GET variables.


    exactly, i’m a beginner and have no real idea what im doing. All i’m trying to do is to get a “are you sure you want to delete your account?” with a continue button to show up when they click delete. Then that message will show and if they click continue well, it will remove them from the database.

    I have no idea how to do this in either javascript or php..

    Some help and clarification would be amazing right now lol..


    Dear Hadley17,

    Im hoping your not planning to use this in a public environment?
    Because if you aren’t able to do this you won’t be able to secure it. Anyway.

    I would suggest you doing the following ( along the lines of ):

    $deleteRequest = $_POST('btnDelete'); //capture the status of the delete from a form that uses the "post" method to submit

    if($deleteRequest == 'true'){
    // if the #deleteRequest value is equal to 'true' then do the following

    mysql_query(" DELETE FROM users WHERE username='$username' ");


    Something like this. It isn’t perfect but I think it’ll work. The difference between GET and POST is crucial to understand. I would suggest you walk through PHP tutorials @ worked wonders for me!



    its not for a public environment, its an assignment for school and im completely lost, so i was searching for help..

    I got whole delete from the database part good to go, although we need to have a confirm delete which i dont know how to do! :( i found a way to show that message and show a continue button, although it doesnt wanna do anything lol


    I got it to work, i realized I had the part that check to see if the continue button was set inside the delete buttons code. I simply removed it and it worked. :)

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Back End’ is closed to new topics and replies.