PHP Login System with Admin Features

Would you like to react to this message? Create an account in a few clicks or log in to continue.
PHP Login System with Admin Features

This forum was created to talk about the PHP Login System with admin features created by jpmaster77 on evolt's website


    Delete Account option

    yearcode
    yearcode


    Number of posts : 2
    Registration date : 2010-06-13

    Delete Account option Empty Delete Account option

    Post  yearcode Sun Jun 13, 2010 12:59 pm

    Hey Everyone, I found something Great!! I created the code myself, its allows your users to delete thier account if they dont want it anymore! It saves your sql data and its good for the user, it even has a warning page before they delete it! Heres the code Create a file called deleteaccount.php and put in the following code:
    deleteaccount.php
    Code:
    <?php
    include("include/session.php");


    if($session->logged_in){

    echo"<h2> Delete Account</h2>

    Hello $session->username!
    <br><p> This is the delete account page. If you press continue you understand your username, password, ect. will be deleted from the database permanantly and you wont be able to login.<br>
    You will be able to register again but all account data will be lost!</p><br><br><a href=delete.php>Continue</a> Or <a href=index.php>Back Out of it</a>";
    }
    else{
    echo"<p> Your not logged in, go and <a href=register.php>Register</a>";
    }
    ?>
    Then create a file called delete.php and insert the following code into it:
    delete.php
    Code:
    <?php
    include("include/session.php");
    ?>


    <?php
    $con = mysql_connect("localhost","username","pass");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }

    mysql_select_db("your_db", $con);
    mysql_query("DELETE FROM users WHERE username='$session->username'");


    if (!mysql_query($sql,$con))
      {
      die('Go back to the <a href=index.php>Homepage</a> Because there was an error.<br> <small> Most likely if you are getting the message ,query was empty, then you are not logged in so the database had nothing to delete</small> <br> The Error was:  '.mysql_error());
      }
    echo "Your username has been deleted, you have no name now so we just call you a guest. You may register again if you like! Also, if you submitted notes they have been submitted. Head back <a href=index.php>Head Home</a> ";
    mysql_close($con);
    ?>
    If you would like to make it an option put this link somewhere in one of your files like main.php or useredit.php:
    Code:
     <a href="deleteaccount.php">Delete My Account</a>
    Unfourtantly you need to enter your database details in the your username, your password, and your database for it to work. Hope someone could make it automatic, but thats the code! Thanks, it was quite simple, im working to improve the script more!

      Current date/time is Fri May 17, 2024 6:16 am