Some trivial administrator interface

For our application, you can create an administrator interface as a single php script, which will allow tables to be cleaned by an administrator. It could be done by simple form, which only allows to execute an SQL command. We don't need even to create a password protected access for this page, simply assume, that administrator should know the database password. Without inserting this, script will not work.

To make only one script, the script should call itself. As a first, it should execute an SQL command, if there is any, then it can offer an input box to write next one. We use the POST method - on the beginning of php, we should check, if there has been sent the correct data in the $_POST array. If not, or if password is wrong, don't show the mysql_query response, and ask for data refill:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<title>Administrator table listing</title>
</head>
<body>
<?php
if ($_POST['submit']=="Execute")  // or: (isset($_POST['submit'])
{
if ($link=mysqli_connect('mysql.webzdarma.cz','zpp',$_POST["pwd"]),'zpp')
{
if (mysqli_real_query($link,$_POST['selline'])) 
{
// response for SELECT should be table, OK/error for the others
if (strtoupper(substr($_POST['selline'],0,6))=="SELECT")
{
$result=mysqli_use_result($link);
 echo "<table border=1>";
  if ($row=mysqli_fetch_assoc($result)) {
   echo "<tr>";
   foreach($row as $key => $value) {echo "<th>".$key; };
   echo "<tr>";
   foreach($row as $key => $value) {echo "<td>".$value; };
  
  }
  
  while ($row=mysqli_fetch_assoc($result)) {
   echo "<tr>";
   foreach($row as $key => $value) {echo "<td>".$value; };
  
  }
 echo "</table>";
} else 
{
 echo "SQL command OK, ";
 echo mysqli_affected_rows($link);
 echo " lines affected";
    } } else {echo "SQL error: ".mysqli_error($link);};

mysqli_close($link); 
} else {echo 'Error connecting database: '.mysqli_error($link) ;};
}
?>
<hr>
Insert a new sql command:
<Form action="admin.php" method="post"><br>
 <input type="text" size="77" name="selline" 
 <?php
 echo "value='".$_POST['selline']."'><br>\n";
 echo 'Database password: <input type="text" name="pwd" value="'.$_POST["pwd"].'">';
 ?> <br>
 <input type="submit" name="submit" value="Execute">
</Form>
</body>
</html>

Change the green texts to your values.

Program should be saved with the name admin.php, or this script name should be changed - it is written in the red as an action parameter of the form. Tested version.