<?php
include("common_db.php");
include("functions.php");
dbconnect($host, $username, $password);
$strings = loadStrings($lang, 'TDELETE');
headers();
html();
head($strings['TD_TITLE'], array('xhr/create-xhr.php?target=\'xhr/get-data.php?action=tl-ops\'%2BString.fromCharCode(38)%2B\'db=\'%2Bindb&caller=reloadTables&tid=tbl&tfunc=clearElem(\'tbl\');'));
menu();
navpane();
echo('<div id="mainpane">');
if(isset($_REQUEST['database'])) {
$db = $_REQUEST['database'];
} else {
if($_SESSION['current_db'] == '') {
echo("<p class=\"alert\">$strings[TD_CHOOSEDB]</p>");
printRequestForm('tbldelete.php');
} else {
$db = $_SESSION['current_db'];
}
}
if(isset($_REQUEST['table'])) {
$table = $_REQUEST['table'];
} else {
echo("<p class=\"alert\">$strings[TD_CHOOSEDB]</p>");
printRequestForm('tbldelete.php',$db);
}
mysql_select_db($db) or die("couldn't select database $db");
if(isset($_REQUEST['confirm'])) {
$query = "DROP TABLE IF EXISTS $table";
if(mysql_query($query))
$tbl_deleted = true;
else
$tbl_deleted = false;
if($tbl_deleted)
printf("<p>$strings[TD_SUCCESS]</p>",$table);
else
printf('<p class="error">' . $strings['TD_FAILED'] . '</p>', mysql_error());
} else {
//print confirmation form
printf('<p class="alert">' . $strings['TD_AREYOUSURE'] . '</p>', $table);
echo('<form action="tbldelete.php" method="post">
<input type="hidden" name="table" value="' . $table . '" />
<input type="hidden" name="database" value="' . $db . '" />
<input type="submit" name="confirm" value="' . $strings['TD_CSUBMIT'] . '" />
</form>');
}
echo('</div>');
endhtml();
?>