• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

[ZNOTE ACC] Changing database with option selected

mano368

Well-Known Member
Joined
Sep 2, 2011
Messages
223
Solutions
27
Reaction score
91
Location
Brazil
Hello friends,
I would like some help on PHP with you, well, I made some changes to play with the code itself, I'll let you know as soon as I don't understand anything about PHP, so don't crucify me.

I put the player option to buy the item in the store, then the same goes on the website and selects the item and which player will send it to, so far so good, but when selecting the item and clicking ok, the code changes the first entry of the database instead of changing the one that corresponds to the selected one.

The problem is that I don't know how to make the code recognize the ID of the selected item and then change it in the database using that same ID.

In the following image, I have 2 items acquired, and I need to change the "player_id" of the item I want to receive to the id of the player who will receive

dabase.jpg

So on the website, I chose to withdraw the fire sword to Blastoise, which in this case corresponds to the second entry of the previous image(yes they are shown in purchase order).
options.jpg

but, when giving ok, unfortunately the item that will receive the player ID will be the first, could you help me?

here is the code used to show the menu and the code that changes the entry inside the database

MENU:
PHP:
                                            <td>
                                                <select id="action" name="action" class="form-control" onChange="changedOption(this)">
                                                    <option value="none" selected>Select action</option>
                                                    <option value="toggle_hide">Toggle hide</option>
                                                    <option value="change_comment">Change Comment</option>
                                                    <?php    $vouchers = mysql_select_multi("SELECT * FROM `znote_shop_orders` WHERE `account_id` = '".(int)$session_user_id."' AND `type` = 1 AND `player_id` = 0 ORDER BY `time` ASC;");
                                                        $items = getItemList();
                                                        foreach(($vouchers ? $vouchers : array()) as $voucher) { ?>
                                                        <option value="delivery_item" '.$voucher['id'].'><?php echo "Withdraw {$items[$voucher['itemid']]}" ?></option>
                                                    <?php } ?>
                                                    <option value="delete_character" class="needconfirmation">Delete character</option>
                                                </select>
                                            </td>
                                            <td id="submit_form">
                                                <?php
                                                    /* Form file */
                                                    Token::create();
                                                ?>
                                                <input id="submit_button" type="submit" value="Submit" class="btn btn-primary btn-block"></input>
                                            </td>

CHANGE CODE:
PHP:
            // delivery items to player
            case 'delivery_item':
                $player = false;
                if ($config['TFSVersion'] === 'TFS_10') {
                    $player = mysql_select_single("SELECT `id`, `account_id` FROM `players` WHERE `name` = '$char_name'");
                }

                // Check if player and account matches
                if ((int)user_character_account_id($char_name) != $player['account_id'] || (int)user_character_account_id($char_name) != $session_user_id) {
                    $errors[] = 'Failed to sync your account. Report if you think this a bug!';
                }

                // Check if player has item to withdraw
                $order = mysql_select_single("SELECT * FROM `znote_shop_orders` WHERE `type` = 1 AND `player_id` = 0 AND `account_id` = '".$player['account_id']."' LIMIT 1;");
                if ($order === false) {
                    $errors[] = 'Your account does not have any items to withdraw!</a>';
                }

                if (empty($errors)) {
                    echo '<font color="green"><b>';
                    echo 'You picked up the item and it will be sent to ' . $char_name . '\'s deppot. Wait up to 30 seconds for it to be delivered.';
                    echo '</b></font>';
                    mysql_update("UPDATE `znote_shop_orders` SET `player_id` = '".$player['id']."' WHERE `id` = '".$order['id']."' LIMIT 1;");
                } else if (!empty($errors)) {
                    echo '<font color="red"><b>';
                    echo output_errors($errors);
                    echo '</b></font>';
                    echo "{$player['id']}";
                }

                break;
            // end
 
Last edited:
Top