Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <body>
- <?php session_start();
- $curUser = $_SESSION['u_name'];
- include('../SQLconfig.php');
- $query = "SELECT * FROM players ;";
- $result = mysql_query($query);
- echo "<table border = ' 0 '>";
- echo "<tr>";
- echo "<p>" . $curUser . "</p>";
- echo "<th>XO Credit Mangement</th>";
- echo "</tr >";
- while($row = mysql_fetch_array($result))
- {
- echo "<tr>";
- $url = "XOCredits.php?username=" . $row['username'];
- echo "<td><a href=" . $url . ">"
- . $row['id']
- . " - "
- . $row['rank']
- . " - "
- . $row['username']
- . " - "
- . $row['credits']
- . "</a></td>";
- echo "</tr>";
- }
- echo "</table>";
- if(isset($_GET['username']))
- {
- $username = $_GET['username'];
- $beforeCredits = $row['credits'];
- echo $username . "<a href='XOCredits.php?add'><button>Add Credits</button></a>" . "<a href='XOCredits.php?minus'><button>Minus Credits</button></a>";
- }
- if(isset($_GET['add']))
- {
- $username = $_GET['username'];
- echo "<u>" . $username . "</u>" ;
- ?>
- <form action='XOCredits.php?ac' method='post'>
- <p>Username: (DEBUG ONLY, DO NOT CHANGE)</p>
- <input type='text' name='user' value='<?php echo $username; ?>'><br />
- <p>Add Credits Amount:</p>
- <input type='text' name='amount' />
- <br />
- <input type='submit' name='submit' value='Submit' />
- </form>
- <?php
- }
- if(isset($_GET['minus']))
- {
- $username = $_GET['username'];
- echo "<u>" . $username . "</u>" ;
- ?>
- <form action='XOCredits.php?mc' method='post'>
- <p>Username: (DEBUG ONLY, DO NOT CHANGE)</p>
- <input type='text' name='user' value='<?php echo $username; ?>'><br />
- <p>Take Away Credits Amount:</p>
- <input type='text' name='amount' />
- <br />
- <input type='submit' name='submit' value='Submit' />
- </form>
- <?php
- }
- if(isset($_GET['ac']))
- {
- $type = "add";
- $amount = $_POST['amount'];
- $afterCredits = $beforeCredits + $amount ;
- $sentFrom = $curUser ;
- $sentTo = $_POST['user'];
- $query = "INSERT INTO creditlog (sentFrom,sentTo,amount,type)
- VALUES ('$sentFrom','$sentTo','$afterCredits','$type');";
- mysql_query($query) or die (mysql_error());
- echo $query;
- $credits = $afterCredits;
- $query2 = ("UPDATE players SET credits='$credits' WHERE username='$sentTo'
- ;")or die(mysql_error());
- mysql_query($query2);
- echo $query2;
- }
- if(isset($_GET['mc']))
- {
- $type = "minus";
- $amount = $_POST['amount'];
- $afterCredits = $beforeCredits - $amount ;
- $sentFrom = $_SESSION['u_name'];
- $sentTo = $_POST['user'];
- $query = "INSERT INTO creditlog (sentFrom,sentTo,amount,type)
- VALUES ('$sentFrom','$sentTo','$afterCredits','$type');";
- mysql_query($query) or die (mysql_error());
- echo $query;
- $credits = $afterCredits;
- $query2 = ("UPDATE players SET credits='$credits' WHERE username='$username'
- ;")or die(mysql_error());
- mysql_query($query2);
- echo $query2;
- }
- ?>
- <br /><a href="index.php"><button>Home</button></a>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement