Jump to content

php create bew database/ user and tables


faces3

Recommended Posts

Hey!

Need script with webform where i put database name. Username and password and it create new mysql database. I dont want do it phpmyadmin. I want do it in website. I try and try all different things but it dont work. Can someone help me ?

Is it possible to do that?

Thanks for help!

Link to comment
https://forums.phpfreaks.com/topic/276712-php-create-bew-database-user-and-tables/
Share on other sites

It is possible but can i ask why? It would only work once as you can only have one database connected to website at any one time. are you sure you don't want to just create a new table?

 

 

 

<?php
$con=mysqli_connect("example.com","peter","abc123");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

// Create database
$sql="CREATE DATABASE my_db";
if (mysqli_query($con,$sql))
  {
  echo "Database my_db created successfully";
  }
else
  {
  echo "Error creating database: " . mysqli_error();
  }
?>
 

as taken from W3C schools

 

You would need to create an input form and use POST if you want it to be user controlled,

I want create install file first is form where put folder name and then unzip files to that folder. Then create new database and tables.

And then create subdomain for that folder name. That script need own files and database to all subdomain. And i want i can do allthing in website install file. Just open www.domain.com and i can do allthing there. Dont need lgin phpmyadmin.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.