I have the following php code that I call in a flash chat program I have. Basically what I am doing is the user types in a username in my flash program, clicks login and it sends the username to my database. Then there is a logout button, when it is clicked, it will called the '&logout' code. So what I need the logout code to do is delete that username the person was using from the database. Anyone think they can help me out here and point me in the right direction.
This first bit is here only until I get the database stuff working, so right now I have the usernames being sent to a txt file as well as the database.
<?php
// remove excess chars and keyboard inputs
$nick = str_replace ( "\n","", $nickname );
$nick = str_replace ( "\r","", $nick );
$nick = str_replace ( "<", "", $nick );
$nick = str_replace ( ">", "", $nick );
$nick = stripslashes ( $nick );
// get the text files
$login = "login.txt";
$fplog= fopen( $login, "a+" );
$fwlog = fwrite( $fplog, "$nick\n" );
fclose( $fplog );
?>
&logged=
<?php
require("settings.php");
@mysql_select_db("$DBName") or die("Unable to select
database $DBName");
$sqlquery = "INSERT INTO $table
VALUES('$id','$nick')";
$results = mysql_query($sqlquery);
mysql_close();
$login = "login.txt";
$tempLogin = file( $login );
$valid = implode( "", $tempLogin );
echo $valid;
?>
&logout=
<?php
require("settings.php");
@mysql_select_db("$DBName") or die("Unable to select
database $DBName");
$sqlquery = "DELETE nick FROM $table
WHERE nick = '$nick';";
$results = mysql_query($sqlquery);
mysql_close();
?>