<?php
function db_connect() {
$database_name = 'xxxxxxx'; // Set this to your Database Name
$database_username = 'xxxxxxx'; // Set this to your MySQL username
$database_password = 'xxxxxxx'; // Set this to your MySQL password
$result = mysql_pconnect('localhost',$database_username, $database_password);
if (!$result) return false;
if (!mysql_select_db($database_name)) return false;
return $result;
}
$conn = db_connect(); // Connect to database
$query;
$type = isset($_REQUEST['pr']) ? $_REQUEST['pr'] : '';
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : '';
$fn = isset($_REQUEST['fn']) ? $_REQUEST['fn'] : '';
$ln = isset($_REQUEST['ln']) ? $_REQUEST['ln'] : '';
$ad = isset($_REQUEST['ad']) ? $_REQUEST['ad'] : '';
$ct = isset($_REQUEST['ct']) ? $_REQUEST['ct'] : '';
$st = isset($_REQUEST['st']) ? $_REQUEST['st'] : '';
$zp = isset($_REQUEST['zp']) ? $_REQUEST['zp'] : '';
$cn = isset($_REQUEST['cn']) ? $_REQUEST['cn'] : '';
$ph = isset($_REQUEST['ph']) ? $_REQUEST['ph'] : '';
if ( $type == "Update") {
$query = "UPDATE GUEST SET "
. "F_NAME = '" . $fn
. "', L_NAME = '" . $ln
. "', STR_ADDRESS = '" . $ad
. "', CITY = '" . $ct
. "', STATE = '" . $st
. "', ZIP = " . $zp
. ", COUNTRY = '" . $cn
. "', PHONE_Num = '" . $ph
. "' WHERE GUEST_ID = " . $id;
}
if ( $type == "Add") {
$query = "INSERT INTO GUEST "
. "(F_NAME, L_NAME, STR_ADDRESS, "
. "CITY, STATE, ZIP, COUNTRY, PHONE_Num)"
. " VALUES ("
. "'" . $fn . "', '" . $ln
. "', '" . $ad . "', '" . $ct
. "', '" . $st . "', " . $zp
. ", '" . $cn . "', '" . $ph . "')";
}
if ( $type == "Delete") {
$query = "DELETE FROM GUEST WHERE GUEST_ID = " . $id;
}
echo $query;
if ($conn && $query != "") {
$result = mysql_query($query,$conn);
}
?>
bobj3.onClick = function(text){ // When Button 3 is clicked
if(live_button){ // If Button 3 is activated
var Da = new Date();
// Create url to send delete command to data2.php program
var tmp = "/data2.php?pr=Delete" +
"&id=" + input1.getControlText() +
"&m=" + Da.getTime(); // Done to deal with page cacheing
output.setControlText(tmp); // Output URL to Debug text field
sendRequest(tmp); // Send URL
clear_form(); // Clear Member Form Field
pausecomp(1250); // Pause program to give database time to update
load("data.php?t=guest"); // Retrive Reload Members table
}
};
This topic is archived.