[request-script]delete my account

This is guide mostly for website tools and code, for example CMS or registration scripts.
There can also be tools.

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

[request-script]delete my account

Postby Blackdpd on Sun Mar 02, 2008 1:08 am

as the titel says it im using dynastyCMS and when you login in the user panel the delete my account does not work.

so can someone help me with that? ;)

Blackdpd `
Last edited by Blackdpd on Tue Mar 04, 2008 8:40 pm, edited 1 time in total.
User avatar
Blackdpd
El Verloon Marshall
El Verloon Marshall
 
Posts: 900
Joined: Sun Jan 27, 2008 10:06 pm
Location: The Netherlands

Re: [request-script]delete my account

Postby Rifke on Mon Mar 03, 2008 7:04 pm

I'll make you a new one to implant if you tell me what you need exactly. Just a regular account delete function or do you want some extra's?
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: [request-script]delete my account

Postby Blackdpd on Mon Mar 03, 2008 8:25 pm

only that when you login you can delete your own account plus all your items( list friend, storage etc.) in the database.

This is what i have right now but it doesnt work.

  1. if(!session_is_registered(User_Name)) {
  2. die('You must log in!');
  3. }
  4.  
  5. if(!session_is_registered(User_Pass)) {
  6. die('You must log in!');
  7. }
  8. ?>
  9.  
  10. <?php
  11. $result1 = mysql_query("SELECT * FROM accounts WHERE username = '".$_SESSION['account']."' ORDER BY id LIMIT 1");
  12.  
  13. while($row = mysql_fetch_array( $result1 )) {
  14.  
  15. echo "<strong>Delete account:&nbsp;".$row['id']."?<BR></strong>";
  16. }
  17.  
  18. ?>
  19. <p align="center">
  20. <form id="form1" name="form1" method="post" action="?op=delete_acc">
  21. <td class="center">
  22. <input name="submit" type="submit" id="submit" value="Confirm" size="15" maxlength="15" />
  23. </form>
  24.  
  25. <?php
  26. if(isset($_POST['submit'])) {
  27. $result = mysql_query("DELETE FROM accounts WHERE id = '".$row['id']."'");
  28. $result = mysql_query("DELETE FROM items WHERE owner = '".$row['id']."'");
  29. $result = mysql_query("DELETE FROM characters WHERE id = '".$row['id']."'");
  30. $result = mysql_query("DELETE FROM list_quest WHERE owner = '".$row['id']."'");
  31. $result = mysql_query("DELETE FROM list_friend WHERE id = '".$row['id']."'");
  32. $result = mysql_query("DELETE FROM storage WHERE owner = '".$row['id']."'");
  33.  
  34. if(!$result) {
  35. echo('Cannot delete you!');
  36. }
  37. else {
  38. echo("Your account have been deleted, goodbye.");
  39. }
  40. }
  41. ?>
  42.  


and what do you mean by extras?( now im interested in your offer :P )

Blackdpd `
Last edited by Blackdpd on Tue Mar 04, 2008 8:41 pm, edited 1 time in total.
User avatar
Blackdpd
El Verloon Marshall
El Verloon Marshall
 
Posts: 900
Joined: Sun Jan 27, 2008 10:06 pm
Location: The Netherlands

Re: [request-script]delete my account

Postby Jckf on Mon Mar 03, 2008 8:49 pm

Blackdpd wrote:only that when you login you can delete your own account plus all your items( list friend, storage etc.) in the database.

This is what i have right now but it doesnt work.

  1. if(!session_is_registered(User_Name)) {
  2. die('You must log in!');
  3. }
  4.  
  5. if(!session_is_registered(User_Pass)) {
  6. die('You must log in!');
  7. }
  8. ?>
  9.  
  10. <?php
  11. $result1 = mysql_query("SELECT * FROM accounts WHERE username = '".$_SESSION['account']."' ORDER BY id LIMIT 1");
  12.  
  13. while($row = mysql_fetch_array( $result1 )) {
  14.  
  15. echo "<strong>Delete account:&nbsp;".$row['id']."?<BR></strong>";
  16. }
  17.  
  18. ?>
  19. <p align="center">
  20. <form id="form1" name="form1" method="post" action="?op=delete_acc">
  21. <td class="center">
  22. <input name="submit" type="submit" id="submit" value="Confirm" size="15" maxlength="15" />
  23. </form>
  24.  
  25. <?php
  26. if(isset($_POST['submit'])) {
  27. $result = mysql_query("DELETE FROM accounts WHERE id = '".$row['id']."'");
  28. $result = mysql_query("DELETE FROM items WHERE owner = '".$row['id']."'");
  29. $result = mysql_query("DELETE FROM characters WHERE id = '".$row['id']."'");
  30. $result = mysql_query("DELETE FROM list_quest WHERE owner = '".$row['id']."'");
  31. $result = mysql_query("DELETE FROM list_friend WHERE id = '".$row['id']."'");
  32. $result = mysql_query("DELETE FROM storage WHERE owner = '".$row['id']."'");
  33.  
  34. if(!$result) {
  35. echo('Cannot delete you!');
  36. }
  37. else {
  38. echo("Your account have been deleted, goodbye.");
  39. }
  40. }
  41. ?>
  42.  


and what do you mean by extras?( now im interested in your offer :P )

Did you make this? If you did, you should look in the MyCMS thread and pick up the tips I got in there (for PHP and MySQL).
User avatar
Jckf
Antares
Antares
 
Posts: 338
Joined: Wed Nov 28, 2007 1:09 am
Location: Norway

Re: [request-script]delete my account

Postby Blackdpd on Mon Mar 03, 2008 9:01 pm

no no i did not make this.... this is from dynastyCMS 7

Blackdpd `
Last edited by Blackdpd on Tue Mar 04, 2008 8:41 pm, edited 1 time in total.
User avatar
Blackdpd
El Verloon Marshall
El Verloon Marshall
 
Posts: 900
Joined: Sun Jan 27, 2008 10:06 pm
Location: The Netherlands

Re: [request-script]delete my account

Postby Rifke on Mon Mar 03, 2008 10:07 pm

You know what's funny it would actualy delete someone else his inventory items :)


I'll work something out asp
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: [request-script]delete my account

Postby Rifke on Mon Mar 03, 2008 10:32 pm

Quickly written something, I haven't tested it myself but there are no syntax errors in there.


New one with fixed mysql issues: 04/03/2008
  1.  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  6. <title>Account deleting :: <?php echo $_SESSION['account']; ?></title>
  7. </head>
  8. <body>
  9. <?php
  10. if ( !isset($_SESSION['account']) ) {
  11.     echo 'This page is restricted. You have to logon before you can access this page.';
  12. } else {
  13.     echo '<h3>Account deleting</h3>';
  14.     $is_deleted = false;
  15.     if ( ($_SERVER['REQUEST_METHOD'] == 'POST') && isset($_POST['Delete']) && ($_POST['delete_check'] == 1) ) {
  16.         $sql = "SELECT id,online FROM accounts WHERE username='".mysql_real_escape_string($_SESSION['account'])."' LIMIT 1"; // it's better to use the account's ID... fail save...
  17.         $qry = @mysql_query($sql);
  18.         if ( $qry === false ) {
  19.             echo 'We could not delete your account due a database issue.';
  20.         } elseif ( mysql_num_rows($qry) == 0 ) {
  21.             echo 'We could not find your account? probaly there has gone something wrong with loggin in. Please relog.';
  22.         } else {
  23.             $arr = mysql_fetch_assoc($qry);
  24.             $username_id = $arr['id'];
  25.             if ( $arr['online'] == 1 ) {
  26.                 echo 'Please logout of the game before deleting your account. If you're already logged out, try to relogin. This issue commenly happens when the game crashes.';
  27.             } else {
  28.                 $sql = "SELECT id FROM characters WHERE account_name='".$_SESSION['account']."' ";
  29.                 $qry = @mysql_query($sql);
  30.                 if ( $qry === false ) echo 'We could not delete your characters, due a database issue.';
  31.                 elseif ( mysql_num_rows($qry) == 0 ) {
  32.                     // empty step...;
  33.                 } else {
  34.                     // loop through characters.
  35.                     while ( $arr = mysql_fetch_assoc($qry) ) {
  36.                         // actualy we hope everyting goes well.. :) else we could make a cleanup scrip that checkes the whole database and deletes inconsitent data.
  37.                         // Ask me and I might make one.
  38.                         $result = mysql_query("DELETE FROM items WHERE owner = '".$arr['id']."'");
  39.                         $result = mysql_query("DELETE FROM characters WHERE id = '".$arr['id']."'");
  40.                         $result = mysql_query("DELETE FROM list_quest WHERE owner = '".$arr['id']."'");
  41.                         $result = mysql_query("DELETE FROM list_friend WHERE id = '".$arr['id']."'");      
  42.                     }
  43.                     // now we remove the storage and the account..
  44.                         $result = mysql_query("DELETE FROM storage WHERE owner = '".$username_id."'");
  45.                         if ( $result === false ) {
  46.                             echo 'Could not empty your storage...';
  47.                         } else {
  48.                             $result = mysql_query("DELETE FROM accounts WHERE id = '".$username_id."'");
  49.                             if ( $result === false ) {
  50.                                 echo 'Could not delete your account name...';
  51.                             } else {
  52.                                 echo 'Account successfullly deleted.';
  53.                                 $is_deleted = true;
  54.                             }
  55.                         }
  56.                 }
  57.             }
  58.         }
  59.     } if ( $is_deleted === false ) {
  60.     echo '
  61.     <form id="form1" name="form1" method="post" action="">
  62.       <table width="100%" border="0" cellspacing="5" cellpadding="2">
  63.         <tr>
  64.           <td width="20px"><input name="delete_check" type="checkbox" id="delete_check" value="1" /></td>
  65.           <td align="center">You have to <strong>check</strong> the checkbox on the right before you can delete your account by clicking the <strong>delete button</strong> on the right. </td>
  66.           <td width="50px"><input name="Delete" type="submit" id="Delete" value="Delete" /></td>
  67.         </tr>
  68.       </table>
  69.     </form>';
  70.     }
  71. }
  72. ?>
  73. </body>
  74. </html>
  75.  
Attachments
account_delete_script.txt
(3.4 KiB) Downloaded 347 times
Last edited by Rifke on Tue Mar 04, 2008 8:11 pm, edited 1 time in total.
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: [request-script]delete my account

Postby Blackdpd on Mon Mar 03, 2008 10:57 pm

it doesnt work .. ( you do know this is for users and not for admin or me .. because you have somehing like this in it : // now we remove the storage and the account..
they dont have to know that right. :P
only that its succesfull or not. )
but i get : This page is restricted. You have to logon before you can access this page.
( also they dont have to see what number there account is dont know if you see it but its just something i like to have it so they dont see it )

lets say it like this: i want an account delete script that it will delete their own account and they dont see what number account they have and they only know that there account successfully has been deleted or not.
also what do you mean by extras?

( and i diddent see this first i want to see this working so i can see if its good )

im srry if im to much of a trouble or something its only that you know what i want..

http://77.250.178.194/ ( try it yourself, register if you want and delete your own account. )

and this was the normal delete account that doesnt work :

  1. <?php
  2. /*
  3. DynastyCMS
  4. Copyrigt (C) 2007 dynastycms
  5.  
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  19. */
  20.  
  21. if(!session_is_registered(User_Name)) {
  22. die('You must log in you noob!');
  23. }
  24.  
  25. if(!session_is_registered(User_Pass)) {
  26. die('You must log in you noob!');
  27. }
  28. ?>
  29.  
  30. <?php
  31. $result1 = mysql_query("SELECT * FROM accounts WHERE username = '".$_SESSION['account']."' ORDER BY id LIMIT 1");
  32.  
  33. while($row = mysql_fetch_array( $result1 )) {
  34.  
  35. echo "<strong>Delete account:&nbsp;".$row['id']."?<BR></strong>";
  36. }
  37.  
  38. ?>
  39. <p align="center">
  40. <form id="form1" name="form1" method="post" action="?op=delete_acc">
  41. <td class="center">
  42. <input name="submit" type="submit" id="submit" value="Confirm" size="15" maxlength="15" />
  43. </form>
  44.  
  45. <?php
  46. if(isset($_POST['submit'])) {
  47. $result = mysql_query("DELETE FROM accounts WHERE id = '".$row['id']."'");
  48. $result = mysql_query("DELETE FROM items WHERE owner = '".$row['id']."'");
  49. $result = mysql_query("DELETE FROM characters WHERE id = '".$row['id']."'");
  50. $result = mysql_query("DELETE FROM list_quest WHERE owner = '".$row['id']."'");
  51. $result = mysql_query("DELETE FROM list_friend WHERE id = '".$row['id']."'");
  52. $result = mysql_query("DELETE FROM storage WHERE owner = '".$row['id']."'");
  53.  
  54. if(!$result) {
  55. echo('Cannot delete you!');
  56. }
  57. else {
  58. echo("You have been deleted, goodbye.");
  59. }
  60. }
  61. ?>
  62.  
  63.  


Blackdpd `
User avatar
Blackdpd
El Verloon Marshall
El Verloon Marshall
 
Posts: 900
Joined: Sun Jan 27, 2008 10:06 pm
Location: The Netherlands

Re: [request-script]delete my account

Postby Rifke on Mon Mar 03, 2008 11:53 pm

I never output the account id. No where in my script I output the account id. Than you just change the things that tell you when it's wrong... Your old one shows up the account id:
  1. echo "<strong>Delete account:&nbsp;".$row['id']."?<BR></strong>";


This page is restricted. You have to logon before you can access this page. you might get that at because the dynasty CMS is using old code.


line: if ( !isset($_SESSION['User_Name']) ) {
based on line: if(!session_is_registered(User_Name)) {

What makes you think it is for admin use?


And you don't just copy pase it onto your page. It's made as stand alone page. Not to be included. If you want to include it remove the tages from <html> until <body> and from </body> until </html>

-----------------------------------------------------------------------------------------
Other comments
Old script:
  1.  
  2. <?php
  3. if(isset($_POST['submit'])) {
  4. $result = mysql_query("DELETE FROM accounts WHERE id = '".$row['id']."'");
  5. $result = mysql_query("DELETE FROM items WHERE owner = '".$row['id']."'");
  6. $result = mysql_query("DELETE FROM characters WHERE id = '".$row['id']."'");
  7. $result = mysql_query("DELETE FROM list_quest WHERE owner = '".$row['id']."'");
  8. $result = mysql_query("DELETE FROM list_friend WHERE id = '".$row['id']."'");
  9. $result = mysql_query("DELETE FROM storage WHERE owner = '".$row['id']."'");
  10.  
  11. if(!$result) {
  12. echo('Cannot delete you!');
  13. }
  14. else {
  15. echo("Your account have been deleted, goodbye.");
  16. }
  17. ?>
  18.  


It would mostly generate the message: Your account have been deleted, goodbye. unless the query for deleting the storage has failed. Or as all other queries fail.
  1. $result = true;
  2. $result = true;
  3. $result = false;
  4. $result = true;
  5. $result = true;
  6. $result = true;

Outputted line: Your account have been deleted, goodbye.
BUT
  1. $result = true;
  2. $result = true;
  3. $result = true;
  4. $result = true;
  5. $result = true;
  6. $result = false;

Outputted line: Cannot delete you!
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: [request-script]delete my account

Postby Blackdpd on Tue Mar 04, 2008 12:09 am

ok i should say that im a moron with coding and with this :P
but i dont really know what to delete i'll show you what i have now. im so srry for all the trouble..

  1. <?php
  2. if ( !isset($_SESSION['User_Name']) ) {
  3.     echo 'This page is restricted. You have to logon before you can access this page.';
  4. } else {
  5.     echo '<h3>Account deleting</h3>';
  6.     $is_deleted = false;
  7.     if ( ($_SERVER['REQUEST_METHOD'] == 'POST') && isset($_POST['Delete']) && ($_POST['delete_check'] == 1) ) {
  8.         $sql = "SELECT id,online FROM accounts WHERE username='".mysql_real_escape_string($_SESSION['username'])."' LIMIT 1"; // it's better to use the account's ID... fail save...
  9.         $qry = @mysql_query($sql);
  10.         if ( $qry === false ) {
  11.             echo 'We could not delete your account due a database issue.';
  12.         } elseif ( mysql_num_rows($qry) == 0 ) {
  13.             echo 'We could not find your account? probaly there has gone something wrong with loggin in. Please relog.';
  14.         } else {
  15.             $arr = mysql_fetch_assoc($qry);
  16.             $username_id = $arr['id'];
  17.             if ( $arr['online'] == 1 ) {
  18.                 echo 'Please logout of the game before deleting your account. If you're already logged out, try to relogin. This issue commenly happens when the game crashes.';
  19.             } else {
  20.                 $sql = "SELECT id FROM characters WHERE owner='".$_SESSION['username']."' ";
  21.                 $qry = @mysql_query($sql);
  22.                 if ( $qry === false ) echo 'We could not delete your characters, due a database issue.';
  23.                 elseif ( mysql_num_rows($qry) == 0 ) {
  24.                     // empty step...;
  25.                 } else {
  26.                     // loop through characters.
  27.                     while ( $arr = mysql_fetch_assoc($qry) ) {
  28.                         // actualy we hope everyting goes well.. :) else we could make a cleanup scrip that checkes the whole database and deletes inconsitent data.
  29.                         // Ask me and I might make one.
  30.                         $result = mysql_query("DELETE FROM items WHERE owner = '".$arr['id']."'");
  31.                         $result = mysql_query("DELETE FROM characters WHERE id = '".$arr['id']."'");
  32.                         $result = mysql_query("DELETE FROM list_quest WHERE owner = '".$arr['id']."'");
  33.                         $result = mysql_query("DELETE FROM list_friend WHERE id = '".$arr['id']."'");      
  34.                     }
  35.                     // now we remove the storage and the account..
  36.                         $result = mysql_query("DELETE FROM storage WHERE owner = '".$username_id."'");
  37.                         if ( $result === false ) {
  38.                             echo 'Could not empty your storage...';
  39.                         } else {
  40.                             $result = mysql_query("DELETE FROM accounts WHERE id = '".$username_id."'");
  41.                             if ( $result === false ) {
  42.                                 echo 'Could not delete your account name...';
  43.                             } else {
  44.                                 echo 'Account successfullly deleted.';
  45.                                 $is_deleted = true;
  46.                             }
  47.                         }
  48.                 }
  49.             }
  50.         }
  51.     } if ( $is_deleted === false ) {
  52.     echo '
  53.     <form id="form1" name="form1" method="post" action="">
  54.       <table width="100%" border="0" cellspacing="5" cellpadding="2">
  55.         <tr>
  56.           <td width="20px"><input name="delete_check" type="checkbox" id="delete_check" value="1" /></td>
  57.           <td align="center">You have to <strong>check</strong> the checkbox on the right before you can delete your account by clicking the <strong>delete button</strong> on the right. </td>
  58.           <td width="50px"><input name="Delete" type="submit" id="Delete" value="Delete" /></td>
  59.         </tr>
  60.       </table>
  61.     </form>';
  62.     }
  63. }
  64. ?>


ive got it like this now and still get the same response.

( ok i get your comments i understand that. )

Blackdpd `
User avatar
Blackdpd
El Verloon Marshall
El Verloon Marshall
 
Posts: 900
Joined: Sun Jan 27, 2008 10:06 pm
Location: The Netherlands

Next

Return to PHP / Web Guides, Scripts and tools.

Who is online

Users browsing this forum: No registered users and 1 guest