MySQL
  Home arrow MySQL arrow Page 2 - MySQL Table Prefix Changer Tool in PHP
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MYSQL

MySQL Table Prefix Changer Tool in PHP
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 14
    2008-01-02

    Table of Contents:
  • MySQL Table Prefix Changer Tool in PHP
  • Constructing the tool
  • Editing your current database tables
  • Putting the database back together

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    MySQL Table Prefix Changer Tool in PHP - Constructing the tool


    (Page 2 of 4 )

    This tool should take a very simple approach. It should display a form where you can enter all of the required information for your database. When the form is submitted, it should connect to the database and make the necessary changes.

    That seems simple enough, wouldn’t you say?

    Please take into consideration that this is designed to be a single use tool. This file should not be left on your web server after use to prevent malicious behavior.  However, we’ll attempt to add a little security just in case it is.

    <html>

    <head>

    <title>MySQL Table Prefix Changer</title>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    </head>

     

    <body>

    <?php

    // Check for POST data

    $action = isset($_REQUEST['action'])?$_REQUEST['action']:false;

     

    if (!$action) {

    ?>

    The code begins quite simply by creating a page. This is pretty standard for any PHP utility.  After setting up the HTML page, we do a quick check for POST data.  This lets us know whether we should display the form itself, or process its data.

    Here we’re using a pretty standard POST data check. Then we move into a conditional statement. The first block of code should be displayed if no post data was found. That means that we should be displaying our HTML form.

    <form name="form1" method="post" action="prefix.php">

       <table width="75%" border="0" cellspacing="2" cellpadding="2">

           <tr>

              <td>Enter database name:</td>

              <td><input name="d" type="text" id="d" size="50"></td>

           </tr>

           <tr>

              <td>Enter database user</td>

              <td><input name="u" type="text" id="u" size="50"</td>

           </tr>

           <tr>

              <td>Enter database password:</td>

              <td><input name="p" type="password" id="p" size="50"></td>

           </tr>

           <tr>

              <td>Enter New Prefix:</td>

              <td><input name="n" type="text" id="n" size="50" value="(Do not include
    the trailing underscore)"></td>

           </tr>

           <tr>

              <td>&nbsp;</td>

              <td>&nbsp;</td>

           </tr>

           <tr>

              <td colspan="2" align="center"><input name="action" type="hidden"
    id="action" value="data">

                  <input type="submit" name="Submit" value="Change Table
    Prefixes"></td>

           </tr>

       </table>

    </form>

    Here we have a simple form with a few input boxes for the necessary information.  There’s certainly nothing fancy here and I’ve even elected not to include any type of validation. Since this should only be used by you, the site administrator, it’s safe to assume the user would know what is going on, but you could certainly add some validation if you wished.

    The important thing to note here is the addition of the hidden “action” field. This is used by our POST data check. If this field is omitted, the script will not function and will continually display this form no matter how many times you choose to submit it. You should also note that the form’s action is set back to this script.

    More MySQL Articles
    More By Nilpo


       · From the article:"In some cases, they are even able to append them as POST data...
       · Query strings are in fact GET data. Thank you for your correction.
     

       

    MYSQL ARTICLES

    - Take Some Load off MySQL with MemCached
    - MySQL Table Prefix Changer Tool in PHP
    - Using the SIGNAL Statement for Error Handling
    - Error Handling Examples
    - Error Handling
    - Completing a Search Engine with MySQL and PH...
    - Paginating Result Sets for a Search Engine B...
    - Building a Search Engine with MySQL and PHP 5
    - Using Boolean Operators for Full Text and Bo...
    - PHP, MySQL and the PEAR Database
    - Working with PHP and MySQL
    - Getting PHP to Talk to MySQL
    - Creating an RSS Reader: the Reader
    - MySQL Security Overview
    - Creating the Admin Script for a PHP/MySQL Bl...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT