Jump to content

Archived

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

spike_132000

Internet Game - Transfering Help

Recommended Posts

Hey There, I have this code. it is for my internet game - [a href=\"http://undergroundwarz.samwillis.net\" target=\"_blank\"]http://undergroundwarz.samwillis.net[/a]. I am having problems when i try to use it, what it is supposed to do is, take money from one persons's bank and put it into another, like transfering money between two accounts! Here is the code for "bank4.php"

[code]
<?
include 'connect.php';
session_start();
?>
<link rel="stylesheet" href="style.css">
<?
if (isset($_SESSION['player']))
{

$player=$_SESSION['player'];

$ide=$_POST['id'];
$userstats="SELECT * from km_users where playername='$player'";
$userstats2=mysql_query($userstats) or die("Could not get user stats");
$userstats3=mysql_fetch_array($userstats2);
$tuserstats="SELECT * from km_users where ID='ide'";
$tuserstats2=mysql_query($tuserstats) or die("Could not get other players stats");
$tuserstats3=mysql_fetch_array($tuserstats2);
$gold1=$_POST['gold'];
if ($userstats3[bank]>$gold)
{
$updatebanks="update km_users set gold=gold-'$gold1' where playername='$player'";
$updateother="update km_users set gold=gold+'$gold1' where ID='$ide'";
mysql_query($updatebanks) or die("Could not Update You");
mysql_query($updateother) or die("Could not Update Player");
print "<center>Successfully Transfered $gold gold to $ide.<br>Click <a href='index.php'>here</a> to return";
}
else if ($userstats3[bank]<$gold)
{
print "<center>You do not have that amount of gold to Transfer";
}
else if ($gold=='-')
{
print "<center>You cannot transfer negative amounts";
}
}
else
{
print "<center>You are not logged in"; die();
}
?>
[/code]

Would Someone be able to tell me where I am going wrong... Here is the code from "bank.php" that sends the data to "bank4.php"

[code]
print "<form action='bank4.php' method='post'>ID to Send To: <input type='text' name='id'> Amount to Send: <input type='text' name='id'><input type='submit' value='Transfer Cash'></form>";
[/code]

Thank You in Advance!

Share this post


Link to post
Share on other sites
what exactly is the problem, what is it not doing or what is it doing incorrectly?

Share this post


Link to post
Share on other sites
for starters before i even look at the rest of your code,
[code]
print "<form action='bank4.php' method='post'>ID to Send To: <input type='text' name='id'> Amount to Send: <input type='text' name='id'><input type='submit' value='Transfer Cash'></form>";
[/code]
both your input tags have the same name.

Share this post


Link to post
Share on other sites
You might also want to learn to catch errors. The code you have is error prone simply because you never check any queries actualy worked before trying to use your results.

Share this post


Link to post
Share on other sites

×

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.