The background. There are two databases, one is for available and another for in use. Users will look at a list, find a pc copy its IP and fill out a short form with their IP=, email, date resever and date returning the pc. Now, I want to use the IP(it is the key in both tables) to 1) insert information from the form into the "in use" table 2) use the IP to pull the remaining info from "available" table and insert into "in use" table and 3) delete the row using the IP entered by the user. All my commanda work fine, just not together, its usually the second which pulls the row from "available" table to "in use" ignoring the rest of the form(date reserved, date returned, email) and delete command. Any help appreciated my code is below
<?php
$connect = mysqli_connect("reserve1",
"root", "","server_31");
$status = "";
if(isset($_POST['new']) &&
$_POST['new']==1){
$IPAddress = $_REQUEST['IPAddress'];
$Email = $_REQUEST['Email'];
$Date_Reserved =
$_REQUEST['Date_Reserved'];
$Date_Returned =
$sql= "INSERT INTO servers_in_use
(IPAddress,DateReserved,DateReturned,Email)
VALUES
('$IPAddress','$Date_Reserved',
'$Date_Returned','$Email')";
$sql= "INSERT INTO servers_in_use
(IPAddress, Manufacturer,Model, BIOSDate,
BIOSFamily, SerialNumber) SELECT
IPAddress,Manufacturer,Model, BIOSDate,
BIOSFamily, SerialNumber FROM servers
WHERE IPAddress = '$IPAddress'";
$sql="DELETE FROM servers WHERE IPAddress =$IPAddress";
if ($connect->query($sql) === TRUE)
{
echo "New record created successfully";
}
else
{
echo "Error: " . $sql . "<br>" .
$connect->error;
}
$connect->close();
}
?>