SupaUpdate: MySQL Mass Updater

brsy

nah mang
May 12, 2011
1,530
272
SupaUpdate

SupaUpdate is a quick and easy tool that can be used to set one value to a mass amount of data within a database, plus it's secure! Here is the code, put it into a PHP file and name it whatever you want so people can't find it. Afterwards, open the file using a PHP file editor, and edit lines 17-21. Save, then you're done!

Code:
PHP:
<?php
 
/*
 
* Script Name: SupaUpdater
 
* Script Description: Database alterations made easy.
 
* Created by: ChrizPHP
 
* Released on: N/A
 
*
 
* This script was created by ChrizPHP, on behalf of ***** -- an all-around
 
* development group dedicated on providing top-quality products to the
 
* internet.
 
*/
 
 
 
function filter($str) {
 
    mysql_real_escape_string(htmlentities($str));
 
}
 
 
 
$supa['dbDatabase'] = 'bullet'; // database that has your hotel's DB.
 
$supa['dbUsername'] = 'root'; // username to connect to database (usually root)
 
$supa['dbHostname'] = 'localhost'; // hostname for databases (usually localhost)
 
$supa['dbPassword'] = 'abc123'; // password used to connect to database
 
$supa['adminPassword'] = 'supaPassword'; // password used to sign into SupaUpdate
 
 
 
$connect = mysql_pconnect($supa['dbHostname'], $supa['dbUsername'], $supa['dbPassword']);
 
mysql_select_db($supa['dbDatabase'], $connect);
 
 
 
if(isset($_POST['done'])) {
 
    $column = filter($_POST['column']);   
 
    $value = filter($_POST['value']);
 
    $table = filter($_POST['table']);
 
        mysql_query("UPDATE ".$table." SET ".$column." = '".$value."'");
 
        $error = mysql_error();
 
        if(isset($error)) {
 
            die($error. '<br /><b>Refresh the page to try again.<b>');
 
        }
 
}
 
 
 
if(!isset($_SESSION['logged'])) { ?>
 
<form action="" method="POST">
 
    <label>Administrative Password:</label>
 
    <input type="password" name="password" />
 
    <input type="submit" name="login" />
 
</form>
 
    <?php
 
    if(isset($_POST['login'])) {
 
        if($_POST['password'] != $supa['adminPassword']) {
 
            die('The password you have entered does not match the password you have set for supaUpdate. If you have not yet created a password, please edit your SupaUpdate file.');
 
        }
 
        else {
 
            $_SESSION['logged'] = true;
 
        }
 
    }
 
}
 
if(isset($_SESSION['logged'])) {
 
?>
 
<center>
 
    <h3>supaUpdater</h3><hr />
 
    <form method="POST" action="">
 
        <label>Table Name:</label>
 
            <input style="width:175px;" type="text" name="table" />
 
                <br />
 
        <label>Altered Column:</label>
 
            <input style="outline: #FFF000;margin-right:19px;width:175px;" type="text" name="column" />
 
                <br />
 
        <label>New Value: </label>
 
            <input style="margin-left:6px;width:175px;" type="text" name="value" />
 
                <br /><br />
 
        <input type="submit" style="height:30px;width:270px;" value="Make Changes!" name="done" />
 
    </form>
 
</center>
 
<?php } ?>
 

Gajeel

Well-Known Member
Oct 4, 2011
2,411
413
SupaUpdate

SupaUpdate is a quick and easy tool that can be used to set one value to a mass amount of data within a database, plus it's secure! Here is the code, put it into a PHP file and name it whatever you want so people can't find it. Afterwards, open the file using a PHP file editor, and edit lines 17-21. Save, then you're done!

Code:
PHP:
<?php
 
/*
 
* Script Name: SupaUpdater
 
* Script Description: Database alterations made easy.
 
* Created by: ChrizPHP
 
* Released on: N/A
 
*
 
* This script was created by ChrizPHP, on behalf of ***** -- an all-around
 
* development group dedicated on providing top-quality products to the
 
* internet.
 
*/
 
 
 
function filter($str) {
 
    mysql_real_escape_string(htmlentities($str));
 
}
 
 
 
$supa['dbDatabase'] = 'bullet'; // database that has your hotel's DB.
 
$supa['dbUsername'] = 'root'; // username to connect to database (usually root)
 
$supa['dbHostname'] = 'localhost'; // hostname for databases (usually localhost)
 
$supa['dbPassword'] = 'abc123'; // password used to connect to database
 
$supa['adminPassword'] = 'supaPassword'; // password used to sign into SupaUpdate
 
 
 
$connect = mysql_pconnect($supa['dbHostname'], $supa['dbUsername'], $supa['dbPassword']);
 
mysql_select_db($supa['dbDatabase'], $connect);
 
 
 
if(isset($_POST['done'])) {
 
    $column = filter($_POST['column']); 
 
    $value = filter($_POST['value']);
 
    $table = filter($_POST['table']);
 
        mysql_query("UPDATE ".$table." SET ".$column." = '".$value."'");
 
        $error = mysql_error();
 
        if(isset($error)) {
 
            die($error. '<br /><b>Refresh the page to try again.<b>');
 
        }
 
}
 
 
 
if(!isset($_SESSION['logged'])) { ?>
 
<form action="" method="POST">
 
    <label>Administrative Password:</label>
 
    <input type="password" name="password" />
 
    <input type="submit" name="login" />
 
</form>
 
    <?php
 
    if(isset($_POST['login'])) {
 
        if($_POST['password'] != $supa['adminPassword']) {
 
            die('The password you have entered does not match the password you have set for supaUpdate. If you have not yet created a password, please edit your SupaUpdate file.');
 
        }
 
        else {
 
            $_SESSION['logged'] = true;
 
        }
 
    }
 
}
 
if(isset($_SESSION['logged'])) {
 
?>
 
<center>
 
    <h3>supaUpdater</h3><hr />
 
    <form method="POST" action="">
 
        <label>Table Name:</label>
 
            <input style="width:175px;" type="text" name="table" />
 
                <br />
 
        <label>Altered Column:</label>
 
            <input style="outline: #FFF000;margin-right:19px;width:175px;" type="text" name="column" />
 
                <br />
 
        <label>New Value: </label>
 
            <input style="margin-left:6px;width:175px;" type="text" name="value" />
 
                <br /><br />
 
        <input type="submit" style="height:30px;width:270px;" value="Make Changes!" name="done" />
 
    </form>
 
</center>
 
<?php } ?>
What is this for?
 

Gajeel

Well-Known Member
Oct 4, 2011
2,411
413
It's an addon you can make work with any cms to update tables with stuff eg updating a users credits etc
Like for example if I wanted to set all users' credits to 500? This will alter all the datas of the users' credits to 500. Is that what you mean?
 

Xenous

o shi
Nov 15, 2011
383
101
Like for example if I wanted to set all users' credits to 500? This will alter all the datas of the users' credits to 500. Is that what you mean?
Pretty much, especially since it doesn't look like it'll update a single item by itself, e.g. 1 user to 500c. Although I may be wrong haven't really read the code
 

Gajeel

Well-Known Member
Oct 4, 2011
2,411
413
Pretty much, especially since it doesn't look like it'll update a single item by itself, e.g. 1 user to 500c. Although I may be wrong haven't really read the code
Thanks, I really appreciated your help.

ONT: Much better if implemented on housekeeping for Owners.
 

Users who are viewing this thread

Top