Jump to content

[SOLVED] little help with _GET, _POST etc


seany123

Recommended Posts

i don't really know exactly how to explain the help I need.

 

basically in this game im making i have this page...

 

 

<?php

include("lib.php");
define("PAGENAME", "Transfer Points");
$player = check_user($secret_key, $db);

$username = ($_GET['username']);
$amount = ($_GET['amount']);

if (isset($_GET['username']) && ($_GET['amount']) && ($_GET['submit'])) {
    $query = $db->execute("select `id`, `username`, `points` from `players` where `username`like '$username'");
    $member = $query->fetchrow;

    if ($query->recordcount() == 0) {
        include("templates/private_header.php");
        echo "<p />This player doesn't exist!<p />";
        echo "<a href=\"transfer.php\">Transfer Again</a><p />";
        include("templates/private_footer.php");
        exit;
    } else if ($player->points < $amount ) {
        include("templates/private_header.php");
        echo "<p />You cannot send this amount of points!<p />";
        echo "<a href=\"transfer.php\">Transfer Again</a><p />";
        include("templates/private_footer.php");
        exit;
    } else if (!is_numeric($amount)) {
        include("templates/private_header.php");
        echo "<p />You cannot send this amount of points!<p />";
        echo "<a href=\"guild_treasury.php\">Transfer Again</a><p />";
        include("templates/private_footer.php");
        exit;
    } else if ($amount < 0 ) {
        include("templates/private_header.php");
        echo "<p />You cannot send this amount of points!<p />";
        echo "<a href=\"transfer.php\">Transfer Again</a><p />";
        include("templates/private_footer.php");
        exit;
    } else {
        while ($member = $query->fetchrow()) {
            
            //Logging Feature
            //$pointslog = "pointslog.txt";
            //$input = fopen($pointslog, 'a') or die("Cannot Open File.");
            //$stringData = "$player->username transferred $amount points to $username.\n";
            //fwrite($input, $stringData);
            //fclose($input);
            
            $query = $db->execute("update `players` set `points`=? where `username`=?", array($member['points'] + $amount, $username));
            $query1 = $db->execute("update `players` set `points`=? where `id`=?", array($player->points - $amount, $player->id));
            $logmsg = "You were given <b>$amount points</b> by $player->username.";
		addlog($member['id'], $logmsg, $db);
            include("templates/private_header.php");
            echo "<p />You have transferred <b>$amount points</b> to $username.<p />";
            echo "<a href=\"home.php\">Home</a><p />";
            include("templates/private_footer.php");
            exit;
        }
    }
}

include("templates/private_header.php");
?>

<fieldset>
<p />
<legend><b>Transfer points</b></legend>
<p><form method="GET" action="transferpoints.php">
<input type="text" name="username" value="Username" size="20"/><br />
<input type="text" name="amount" value="points" size="20"/><p />
<input type="submit" name="submit" value="Submit">
</form>
</fieldset>

<?php include("templates/private_footer.php");
?>

 

i want a way to instead of once on the page you type in the players username... that the players username is already selected...

 

i thought by using some kind of thing like transfer.php?username=(there name) but i seriously dont know how to go about doing that...

 

and then how to use username= again in a query.

 

Link to comment
https://forums.phpfreaks.com/topic/156699-solved-little-help-with-_get-_post-etc/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.