Skip to main content

Create Database Without Using phpMyAdmin


This tutorial will help you on how to create a database and a database table without opening phpmyadmin. The feature of this program is the user can add database and database table without using phpmyadmin.

to start this tutorial lets follow the steps bellow:

Step 1: Creating The Database Name Form

To create a form, open your php editor and paste the code below and save it as "idex.php".

  1. <form action="exec.php" method="post">
  2. database name:<input type="text" name="datname">
  3. <input type="submit" value="create">
  4. </form>

Step 2: Writing Our Script to Create Database name

Our next step is to write our script that automatically create a database. To do this paste the code bellow to your php editor and save it as "exec.php"

  1. <?php
  2. $con = mysql_connect("localhost","root","");
  3. if (!$con)
  4. {
  5. die('Could not connect: ' . mysql_error());
  6. }
  7. $dddd=$_POST['datname'];
  8. if (mysql_query("CREATE DATABASE $dddd",$con))
  9. {
  10. header('location: createtableform.php?id='.$dddd.'');
  11. }
  12. else
  13. {
  14. echo "Error creating database: " . mysql_error();
  15. }
  16.  
  17. ?>

At this point we are now we can now create a database name without opening phpmyadmin. But we are not yet finish, our next step is to create a form and script that automatically create table in your database created.

Step 3: Creating Our Database Table Form

To create a form, open php editor and paste the code below and save it as "createtableform.php".

  1. Insert your query here:<br>
  2. <form action="savetable.php" method="post">
  3. <input type="hidden" name="datname" value="<?php echo $_GET['id']?>">
  4. <textarea name="asasasa" style="width: 500px; height: 500px;"></textarea><br>
  5. <input type="submit" value="create">
  6. </form>

Step 4: Writing Our Script that automatically create tables in your database

this step is we are going to write the script that will create table in your database. To do so, paste the code below in your php editor and save it as "savetable.php".

  1. <?php
  2. $con = mysql_connect("localhost","root","");
  3. if (!$con)
  4. {
  5. die('Could not connect: ' . mysql_error());
  6. }
  7. // Create table
  8. $dddd=$_POST['datname'];
  9. $asasasa=$_POST['asasasa'];
  10. mysql_select_db($dddd, $con);
  11. $sql = $asasasa;
  12.  
  13. // Execute query
  14. mysql_query($sql,$con);
  15. header('location: createtableform.php');
  16. ?>

That's it you've been successfully created the program that automatically create a database name and table without opening phpmyadmin. Hope this code will help those other php programmer.

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Submitted byHekanksh Gohel (not verified)on Tue, 06/13/2017 - 22:35

Thank You very much for this source code.

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.