I'm simply trying to check if a database with the same name exists (if yes, throw an error) else create it and display it has been created successfully. But after entering the database name, no database is getting created. What could I be missing ? (Is db.php even getting called ?? I think there should be some way for index.html and db.php to communicate , right ?)
This is my index.html
<form method="post" action="">
Enter database name: <input type="text" name="db" /><br/>
<input type="submit" name="submit" value="submit"/>
</form>
And my db.php:
<?php
if(isset($_POST['submit'])){ //check for the submit button pressed
$dbname=$_POST['db']; //store the database name in php variable
$query= mysqli_connect('localhost','root','')or die("Error establishing connection"); //check for database connectivity
$a="CREATE DATABASE IF NOT EXISTS ".$dbname; //create a database if it doesn't already exist
$q= mysqli_query($query, $a) or die("Database already exist.. please try different name");
echo "Your database ".$dbname." is successfully created";
}
?>