Create Database Without Using phpMyAdmin

Submitted by: 
Language: 
Visitors have accessed this post 3937 times.

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.


Comments

Thank You very much for this source code.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.