Donbudz Posted November 11, 2008 Share Posted November 11, 2008 Hi, im new to this forum, and new to PHP, MYSQL. I have a login in flash CS3. Basically its works like: Flash>PHP>MYSQL. My login works fine, however when i user logs in succesfully, i want their username to be entered into a table then delete that same entry when they exit. My table name is: "users_online" field name is: "usersonline". My login.php is: <?php include "connect.php"; $tableName = "usersv2"; $tableName2 = "users_online"; $username = $_POST['username']; $password = md5($_POST['password']); $sql = mysql_query("SELECT * FROM $tableName WHERE username = '$username' and password = '$password'"); $rows = mysql_num_rows($sql); $arr = mysql_fetch_array($sql); $fname = $arr[3]; $lname = $arr[4]; $user = $arr[1]; $email = $arr[5]; $phone = $arr[6]; $address = $arr[7]; $city = $arr[8]; $state = $arr[9]; $zip = $arr[10]; if($rows == 1) { echo "&msgText=Entrance Granted!"; echo "&whosIn=$fname $lname"; echo "&fName=$fname"; echo "&lName=$lname"; echo "&userName=$user"; echo "&email=$email"; echo "&phone=$phone"; echo "&address=$address"; echo "&city=$city"; echo "&state=$state"; echo "&zip=$zip"; $insert = mysql_query("INSERT INTO $tableName2 (usersonline) VALUES ('$username')") or die(mysql_error()); } else { echo "&msgText=Invalid Login!"; } ?> I have a line in login.php that inserts into the table, when user logs in. $insert = mysql_query("INSERT INTO $tableName2 (usersonline) VALUES ('$username')") or die(mysql_error()); How can i delete that entry from the table when user exits? Quote Link to comment https://forums.phpfreaks.com/topic/132296-solved-insert-delete-from-mysql/ Share on other sites More sharing options...
revraz Posted November 11, 2008 Share Posted November 11, 2008 DELETE FROM $tableName2 WHERE usersonline = '$username' Quote Link to comment https://forums.phpfreaks.com/topic/132296-solved-insert-delete-from-mysql/#findComment-687876 Share on other sites More sharing options...
Donbudz Posted November 11, 2008 Author Share Posted November 11, 2008 Thanx for that... so simple but so many ways to DELETE with query. Thanx again. Quote Link to comment https://forums.phpfreaks.com/topic/132296-solved-insert-delete-from-mysql/#findComment-687891 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.