Jump to content

[SOLVED] insert + delete from mysql


Donbudz

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/132296-solved-insert-delete-from-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.