Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deadman's switch: drop all tables from a database with php?

Tags:

php

mysql

I'm working with a client who gives me some reason not to trust him (who hasn't been in that situation). I'm trying to create a "deadman's switch", where all tables in a database will be deleted on submission of a form (in a secret login protected directory).

What I don't know how to do is drop all tables from a database using PHP. I know how to drop columns and rows, and am sure individual tables can be dropped (but there are a lot of tables), but all tables within a database is beyond me.

like image 418
Nathan Avatar asked Dec 27 '22 13:12

Nathan


1 Answers

Why don't you drop the entire database?

DROP DATABASE database_name

Sample Code

<?php
if(isset($_POST['delete_database'])) {
  //Code goes here
}
?>

<form method="post">
 <input type="submit" name="delete_database" value="Delete Entire Database" />
</form>
like image 63
Mr. Alien Avatar answered Feb 12 '23 11:02

Mr. Alien