Drexl Posted April 12, 2012 Share Posted April 12, 2012 I have this donation system on a game I run, basically when someone donates they are automatically given in-game points via my MySQL server. What query should I run so I can give points to someone via the PhpMyAdmin interface. Example (give the user "Drex" 500 points) Below is all the code used. Note copy to notepad to get the correct formatting database.php <?php /** * Variable containing host address. * (Usually localhost). */ $host = "localhost"; /** * Variable containing host username. * (Username used to login to webhost). */ $username = "interbe1"; /** * Variable containing host password. * (Password used to login to webhost). */ $password = "REMOVED"; /** * Variable containing database name; don't worry about adding * a prefix unless your prefix is different than the username. */ $database = "plimus"; /** * Initializes a connection to the webhost. */ $connection = mysql_connect($host, $username, $password); /** * Initializes a connection to the MySQL database. */ mysql_select_db('' . $username . '_' . $database . '', $connection); ?> index.php <?php /** * If the player clicks the continue * button, it will perform the following * process. The process will redirect to * the checkout URL as long as the player * has entered their username details. */ if (isset($_POST['continue'])) { $username = trim($_POST['username']); $points = trim($_POST['points']); if ($username != "Enter Username" && $username != "") { header("Location: http://www.plimus.com/jsp/buynow.jsp?contractId=2279971&custom1=" . $username . "&quantity=".$points); exit; } } ?> <html> <head> <title>Interbellum Plimus</title> </head> <body> <legend>Donate</legend> <p><em>Please enter the username of the acount you wish to recieve Interbellum points on.</em></p><br/> <fieldset class="menu main"> <form action="<?php ?>" method="POST"> <table> <tr> <td>Username:</td> <td><input type="text" maxlength="12" name="username" value="Enter Username" onblur="if(this.value=='') this.value='Enter Username';" onfocus="if(this.value=='Enter Username') this.value='';"/></td> </tr> <tr> <td>How many Interbellum points do you want to buy?</td> <td><input type="text" name="points" value="" /></td> </tr> </table> <?php /** * If the user enters their username details * incorrectly, it will perform this process. * This will just send a line of text asking * them to enter their username. I recommend * carrying over this process when you integrate * it with your own website theme. */ if (isset($_POST['continue'])) echo "<font color=red>Please enter your username.</font>"; ?> <div name="button"> <button type="submit" name="continue" value="Continue">Continue</button> </div> </form> </fieldset> </body> </html> ipn.php <?php /** * @author Jinx <jinx@worldofrunecraft.com> * * Plimus Payment Handler * * Version 1.0.0 * * Automated payment script that will allow players * to retrieve their reward instantly upon making * their payment to Plimus. This is acheived by * having this script import the payment information * directly into the MySQL database when notification * of a payment is received. */ /** * This will initialize the content within your database.php * file to create a connection to the MySQL database. */ include("database.php"); /** * Array containing Plimus' server's addresses. */ $acceptable_connections = array("62.216.234.196", "62.216.234.197", "62.216.234.198", "62.216.234.199", "62.216.234.200", "62.216.234.201", "62.216.234.202", "62.216.234.203", "62.216.234.204", "62.216.234.205", "62.216.234.206", "62.216.234.207", "62.216.234.208", "62.216.234.209", "62.216.234.210", "62.216.234.211", "62.216.234.212", "62.216.234.213", "62.216.234.214", "62.216.234.215", "62.216.234.216", "62.216.234.217", "62.216.234.218", "62.216.234.219", "62.216.234.220", "62.216.234.221", "62.216.234.222", "72.20.107.242", "72.20.107.243", "72.20.107.244", "72.20.107.245", "72.20.107.246", "72.20.107.247", "72.20.107.248", "72.20.107.249", "72.20.107.250", "209.128.93.97", "209.128.93.98", "209.128.93.99", "209.128.93.100", "209.128.93.101", "209.128.93.102", "209.128.93.103", "209.128.93.104", "209.128.93.105", "209.128.93.106", "209.128.93.107", "209.128.93.108", "209.128.93.109", "209.128.93.110", "209.128.93.225", "209.128.93.226", "209.128.93.227", "209.128.93.228", "209.128.93.229", "209.128.93.230", "209.128.93.231", "209.128.93.232", "209.128.93.233", "209.128.93.234", "209.128.93.235", "209.128.93.236", "209.128.93.237", "209.128.93.238", "209.128.93.239", "209.128.93.240", "209.128.93.241", "209.128.93.242", "209.128.93.243", "209.128.93.244", "209.128.93.245", "209.128.93.246", "209.128.93.247", "209.128.93.248", "209.128.93.249", "209.128.93.250", "209.128.93.251", "209.128.93.252", "209.128.93.253", "209.128.93.254", "209.128.93.255"); /** * Denies connections that aren't from a Plimus server. */ if (!array_search($_SERVER['REMOTE_ADDR'], $acceptable_connections)) die("Denied connection from: " . $_SERVER['REMOTE_ADDR'] . "."); /** * Imports payment information into database. */ if (isset($_POST['transactionType'])) { if ($_POST['transactionType'] == "CHARGE") { $replace = array("%20", "-", " "); $username = @mysql_real_escape_string($_POST['Username']); $username = str_replace($replace, "_", $username); $username = @mysql_real_escape_string($username); $points = @mysql_real_escape_string($_POST['points']); $contract_id = 2279971; $date = $_POST['transactionDate']; $fh = fopen("logs", "a"); fwrite($fh, "[".$date."] Username: " .$username." - price: " .$contract_id."\n"); fclose($fh); mysql_query("INSERT INTO donations (username, contract) VALUES ('" . $username . "', '" . $contract_id . "');"); } } ?> Can someone tell me a query that I can execute to give points via PhpMyAdmin. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/260819-please-help-me-find-the-query/ Share on other sites More sharing options...
MarPlo Posted April 12, 2012 Share Posted April 12, 2012 Hi, I think you can open the PhpMyAdmin , and browse the table "donations", then click Insert to add manually a new row. Quote Link to comment https://forums.phpfreaks.com/topic/260819-please-help-me-find-the-query/#findComment-1336788 Share on other sites More sharing options...
Drexl Posted April 12, 2012 Author Share Posted April 12, 2012 I tried this but it didn't add the points in-game. Quote Link to comment https://forums.phpfreaks.com/topic/260819-please-help-me-find-the-query/#findComment-1336789 Share on other sites More sharing options...
fenway Posted April 15, 2012 Share Posted April 15, 2012 I can't find the INSERTs in that code. Quote Link to comment https://forums.phpfreaks.com/topic/260819-please-help-me-find-the-query/#findComment-1337628 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.