<?
$connection = @mysql_connect("localhost", "root", "") or die(mysql_error());;
$dbs = @mysql_list_dbs($connection)or die(mysql_error());
$db_list="<ul>";
$i =0;
while ($i < mysql_num_rows($dbs)){
$db_names[$i] = mysql_tablename($dbs,$i);
$db_list .="<li>$db_names[$i]";
$i++;
}
$db_list .="</ul>";
?>
<HTML>
<HEAD>
<TITLE>MySQL Databases</TITLE>
</HEAD>
<P><strong>Databases on localhost</strong>:</p>
<? echo "$db_list"; ?>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>Adding a Database to MySQL</TITLE>
</HEAD>
<BODY><H3>
<FORM METHOD="post" ACTION="pretask.php">
<P>Database Name
<INPUT TYPE="text" NAME="val1" SIZE=10></P>
<P><INPUT TYPE="submit" NAME="submit" VALUE="Add database"></P>
</FORM>
</BODY></H3>
</HTML>
</font>
<?
$connection = @mysql_connect("localhost", "root", "") or die(mysql_error());
if ($connection) {
$msg = "YES!";
}
$sql = "CREATE DATABASE my_music ";
$result = @mysql_query($sql,$connection) or die(mysql_error())
?>
<HTML>
<BODY>
<h1><center><? echo "$msg"; ?></h1></center>
</BODY>
</HTML>
Add Databse Using post method
Moderator: General Moderators
Add Databse Using post method
Hey im trying to come up with a simple script that shows the databases in my localhost then create a insert box with a "submit button" and when i type in any name lets just say test1234 it should show up in the list and i want it to show the results below such as you successfully added a database. I have started this not too long ago but i've had experience with previous database adding and i just threw it in there to get me started. Here is my code as of now. By the way I am using PHP my admin and i have it so it creates it to the list but it does it automatically but i want it to add it by me typing it in the text box and when i hit the submit button it shows up in the list and below as well.