-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lefty --

...and then BGLefty said...
% 
% 
% Is there a simple php script out there somewhere (or an example of how to do

It's a little bigger than "simple", but have you seen phpMyAdmin?


% it) to create a new database, username and password? I would like to have a
% form in a password protected folder on my web site and be able to fill in
% those three variables to create a new database on my installation of mysql
% on my home computer (be able to do this from my office or another computer).
% It seems like a simple enough thing to do but I have been unable to find any
% examples...

Indeed it should be.  Admittedly, I may be overlooking something since
I've created a user that can't get in, but we can edit this post when I'm
finally shown the problem :-)

So your script should run something like

  if ( not https )
    { redirect to https ; exit ; }

  if ( no or incorrect password )
  {
    check $_POST for password input ;
    get password ;
    exit ;
  }

  if ( $_POST['dbname'] && $_POST['dbuser'] && $_POST['dbpass'] )
  {
    mysql_connect("localhost","dbrootuser","dbrootpass")
      or die("Could not connect\n") ;
    mysql_query("create database {$_POST['dbname']}")
      or die("Could not create db\n") ;
    mysql_query("grant all privileges on {$_POST['dbname']}.* to
      {$_POST['dbuser']} identified by {$_POST['dbname']}
      with grant option")
      or die("Could not create user\n") ;
    mysql_query("flush privileges") ;
  }
  else
    { display input page ; exit ; }

(just from the top of my head, and without any real security checking
since you're the only who will use the script and you know better).  This
will ask for db name, db user, db pass and then connect as your root user
to attempt to create the database and then give the user permissions on
it (thereby creating the user record).


% 
% Any help would be appreciated.
% 
% Thanks,
% BGLefty


HTH & HAND

:-D
- -- 
David T-G                      * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/      Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQFAYBk7Gb7uCXufRwARAl1jAJ9sqzZdGnuKH7aeb+ysh3f7ZtoQqACePK+Y
m7o14jrrXR6aS1/hB7a9yq0=
=CgKZ
-----END PGP SIGNATURE-----

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to