Jump to content

php create bew database/ user and tables


faces3
Go to solution Solved by xxclear,

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
Share on other sites

  • Solution

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,

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.