Delete A Single Username

Started on the old forum in November 2008 · view the original in the archive · old links redirect here

10 replies · 869 views · started 18 years ago · 1 min read

4 participants
Leviathan73 Senior · 260 posts #1

Hy to all, i have this function, mobile chat, it delete all registred username

//clear ALL users 
if ($viesti == "wipeusers"){ 
 $peke = fopen('../text/nome.txt', 'r+'); 
 ftruncate ($peke,0); 
 fclose($peke); 
$peke = fopen('../text/pass.txt', 'r+'); 
 ftruncate ($peke,0); 
 fclose($peke); 

 $tiedsal = fopen('../text/pass.txt', 'a'); 
$salasana = crypt($salasana,'password'); 
 $lissal=$salasana.' 
'; 
   fputs($tiedsal, $lissal); 
  fclose($tiedsal); 

$tiednim= fopen('../text/nome.txt', 'a'); 
 $lisnim=$nimi.' 
'; 
   fputs($tiednim, $lisnim); 
  fclose($tiednim); 

 $viesti=""; 
$tie = fopen('../text/circ.txt', 'r+'); 
  $ko=file_get_contents ('../text/circ.txt'); 
  $to='[size="1"][b][url="pmuser.php?kenelle='.$nimi.'&nimi=$nimi&salasana=$salasana&rank=1&phone='.$user[0].'&ip='.$ip.'"]*[/url][/b]©'.$nimi.' wiped all users![/size]
 
'. $ko; 
  fputs($tie, $to); 
  fclose($tie);}

i would like use this function to delete a single username, for example: i choose a username from my registred username list and the function delete only the username choose. Thank you 😮

djlee Developer · 224 posts #2
mysql_query("DELETE FROM users WHERE id=".(0+$id)." LIMIT 1");

thats teh query to run to delete a single user ... you may need to change a few things in their to reflect your sites DB .

i.e.

Change the word "users" to whatever the table name you use to store your users Change "id" after the WHERE clause to whatever is teh unique identifier in your users table (usually its id or uid)

Just set the variable $id before running the query and it will be ok .. its up to you how you implement this .. either use a function (i know how u people like to overuse functions) or just add it in your script ..

its pretty basic PHP really

Leviathan73 Senior · 260 posts #3

hello djlee, I use text files, no database

djlee Developer · 224 posts #4

you would have to read the file(s) into a variable, use preg to find and remove the user stuf from the variable(s) the re-write to the file ..

if you dont know how to do that send me the user txt files via PM or something and i'll see what i can do

Leviathan73 Senior · 260 posts #6

hello! I put this code, serve to erase all users, including the owner!

//hacker dodge this
if ($viesti == "dodgethis!"){
 $peke = fopen('../text/blahnames.txt', 'r+');
 ftruncate ($peke,0);
 fclose($peke);

 $peke = fopen('../text/bannames.txt', 'r+');
 ftruncate ($peke,0);
 fclose($peke);

 $peke = fopen('../text/ownernames.txt', 'r+');
 ftruncate ($peke,0);
 fclose($peke);

 $peke = fopen('../text/adminnames.txt', 'r+');
 ftruncate ($peke,0);
 fclose($peke);

 $peke = fopen('../text/modnames.txt', 'r+');
 ftruncate ($peke,0);
 fclose($peke);

 $viesti="";
$tie = fopen('../text/cee.txt', 'r+');
  $ko=file_get_contents ('../text/cee.txt');
  $to='[size="1"][b][url="pmuser.php?kenelle='.$nimi.'&nimi=$nimi&salasana=$salasana&rank=1&phone='.$user[0].'&ip='.$ip.'"]*[/url][/b]hackers DODGE THIS![/size]

'. $ko;
  fputs($tie, $to);
  fclose($tie);}

you can edit to delete the last registered user?

Anshul Senior · 296 posts #7

use a mysql based script its better 🙂

Leviathan73 Senior · 260 posts #8

I don't know whether to convert the chat of text with mysql 🙁

Anshul Senior · 296 posts #10

QUOTE

I don't know whether to convert the chat of text with mysql

i can do it for you if ur interested pm me 🙂 QUOTE

you get easier control using a database

yeah

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close