Skip to content

Instantly share code, notes, and snippets.

@viruthagiri
Created January 22, 2012 06:11
Show Gist options
  • Save viruthagiri/1655886 to your computer and use it in GitHub Desktop.
Save viruthagiri/1655886 to your computer and use it in GitHub Desktop.
Mysql database drop
<html>
<head>
<title></title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
H:<input type="text" size="12" maxlength="100" name="hname"/><br />
U:<input type="text" size="12" maxlength="100" name="uname"/><br />
P:<input type="text" size="12" maxlength="100" name="pword"/><br />
D:<input type="text" size="12" maxlength="100" name="dname"/><br />
Action:<input type="text" size="12" maxlength="100" name="action"/><br />
<input type="submit" /><br />
</form>
<?php
$dbhost = $_POST["hname"];
$dbuser = $_POST["uname"];
$dbpass = $_POST["pword"];
$dbname = $_POST["dname"];
$action = $_POST["action"];
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully<br />';
$sql = "$action DATABASE $dbname";
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die("Could not $action database: " . mysql_error());
}
echo "Database $dbname $action successfully\n";
mysql_close($conn);
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment