Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Cash Shower in PHP CODE

Initiate Mage
Joined
Aug 10, 2020
Messages
11
Reaction score
0
PHP:
<?php
// Set database credentials
$serverName = "ServerName";
$connectionInfo = array(
    "Database" => "dnmembership",
    "UID" => "Username",
    "PWD" => "Password"
);

// Initialize variables
$updateStatus = "";
$cashAmount = "";

// Check if the form was submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Validate the cash amount input
    if (empty($_POST["cashAmount"])) {
        $updateStatus = "Please enter a cash amount.";
    } else {
        $cashAmount = $_POST["cashAmount"];
        if (!is_numeric($cashAmount)) {
            $updateStatus = "Cash amount must be a number.";
        } else {
            $cashAmount = (int) $cashAmount;

            // Create a new connection to the database
            $conn = sqlsrv_connect($serverName, $connectionInfo);

            // Check if the connection was successful
            if (!$conn) {
                die("Connection failed: " . sqlsrv_errors());
            }

            // Update the Cash column in the Accounts table for accounts in the list returned by the SELECT query
            $updateSql = "UPDATE Accounts
                          SET Cash = Cash + $cashAmount
                          WHERE AccountName IN (
                              SELECT AccountName
                              FROM dbo.DNAuth
                              WHERE CertifyingStep > 0
                          )";
            $updateStmt = sqlsrv_query($conn, $updateSql);

            if ($updateStmt === false) {
                $updateStatus = "Error updating cash table: " . sqlsrv_errors();
            } else {
                $updateStatus = "Cash Shower Initialize successfully";
            }

            // Close the database connection
            sqlsrv_close($conn);
        }
    }
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Cash Shower</title>
</head>
<body>
    <h1>Cash Shower Cash</h1>
    <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
        <label for="cashAmount">Cash Amount:</label>
        <input type="text" id="cashAmount" name="cashAmount" value="<?php echo $cashAmount; ?>"><br/>
        <input type="submit" value="Update">
    </form>
    <p><?php echo $updateStatus; ?></p>
</body>
</html>


No idea why i share this stuff :sleep:
 
Back
Top