connection.inc.php :
<?php
$host='localhost';
$user_name='root';
$password='';
@$con = mysql_connect("$host","$user_name","$password");
if ($con)
{echo '<br>host coonected<br>';}
else
{
die('Could not connect ');
}
?>
=========================================================
database_creation.php :
<?php
require 'connection.inc.php';
if(isset($_POST['db'])&&!empty($_POST['db']))
{
$db1=$_POST['db'];
if (mysql_query("create database $db1",$con))
{
echo "<br>Database created<br>";
}
else
{
echo '<br>database not created<br> :'.mysql_error().'<br>';
}
}
else
{ echo '<br>please write database name below<br><br>' ; }
mysql_close($con);
?>
<form action="database_creation.php" method="POST">
<input type="text" name="db">
<input type="submit" name="submit">
</form>
===============================================================
run " database_creation.php "
output :
host coonected
please write database name below
host coonected
please write database name below
"here button is there"
<?php
$host='localhost';
$user_name='root';
$password='';
@$con = mysql_connect("$host","$user_name","$password");
if ($con)
{echo '<br>host coonected<br>';}
else
{
die('Could not connect ');
}
?>
=========================================================
database_creation.php :
<?php
require 'connection.inc.php';
if(isset($_POST['db'])&&!empty($_POST['db']))
{
$db1=$_POST['db'];
if (mysql_query("create database $db1",$con))
{
echo "<br>Database created<br>";
}
else
{
echo '<br>database not created<br> :'.mysql_error().'<br>';
}
}
else
{ echo '<br>please write database name below<br><br>' ; }
mysql_close($con);
?>
<form action="database_creation.php" method="POST">
<input type="text" name="db">
<input type="submit" name="submit">
</form>
===============================================================
run " database_creation.php "
output :
host coonected
please write database name below
host coonected
please write database name below
"here button is there"