|
Description
ok, so here is a simple php program i made that will truncate a table from a mysql database. as you can see i have a "global.php" that stores all the login info. (simple to make, just define $host, $username, $password, and $db_name in it) this page is behind a login. if you want to test it, just remove the session_start() and the if else statement dealing with. enjoy!
p.s. i made it for school use, cause i don't have access to my mysql database when i'm in school.
<?php session_start(); include(realpath("../global.php")); if (isset($_SESSION["loggedIn"]) && $_SESSION["loggedIn"] == "true") { mysql_connect ($host,$username,$password); @mysql_select_db ($db_name) or die ("Unable to find a database"); $truncate = mysql_query ("TRUNCATE TABLE Login"); mysql_close(); if ($truncate) { print "<span>Done</span>"; } else { print "<span>Failed</span>"; } } else { print "<span>You must <a href=\"/\">login</a> to view this page.</span>\n"; } ?> |
|