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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.