Running CREATE and GRANT commands
Is Dreamweaver capable of running GRANT and CREATE commands? I want to setup a page that allows users to create their own user and password.
I have tried the following but doesn't seem to work.
<?php require_once('Connections/med.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$createUserSQL = sprintf("CREATE USER %s@'localhost' IDENTIFIED BY %s; GRANT USAGE ON * . * TO %s@'localhost' IDENTIFIED BY %s WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; CREATE DATABASE IF NOT EXISTS %s ; GRANT ALL PRIVILEGES ON %s . * TO %s@'localhost';",
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['username'], "text"));
mysql_select_db($database_med, $med);
$Result1 = mysql_query($createUserSQL, $med) or die(mysql_error());
?>
