API Player Info in PHP Function ?

For general discussion of the Poker Mavens software
PokerFreak
Posts: 19
Joined: Sun Feb 13, 2011 7:05 am

API Player Info in PHP Function ?

Post by PokerFreak »

Hello, I have a form where someone submits a username(account name) and information will be given accordingly. This is the code :

Code: Select all

$account = $_POST['account'];
$params = "Password=$pw&Command=AccountsGet&Player=$account";
$api = Poker_API($url,$params,true);
echo "Username: " . $api["Player"] . "</br>Balance: " . $api["Balance"]  . " ";
It works. But when i try to put the code in a function no info is displayed. Any Help ?
Kent Briggs
Site Admin
Posts: 5880
Joined: Wed Mar 19, 2008 8:47 pm

Re: API Player Info in PHP Function ?

Post by Kent Briggs »

PokerFreak wrote: It works. But when i try to put the code in a function no info is displayed. Any Help ?
Show us the function you wrote so we can see.
PokerFreak
Posts: 19
Joined: Sun Feb 13, 2011 7:05 am

Re: API Player Info in PHP Function ?

Post by PokerFreak »

Code: Select all

function playerInfo() {
$account = $_POST['account'];
$params = "Password=$pw&Command=AccountsGet&Player=$account";
$api = Poker_API($url,$params,true);
echo "Username: " . $api["Player"] . "</br>Balance: " . $api["Balance"]  . " ";
}
Kent Briggs
Site Admin
Posts: 5880
Joined: Wed Mar 19, 2008 8:47 pm

Re: API Player Info in PHP Function ?

Post by Kent Briggs »

And the code where you call the function?
PokerFreak
Posts: 19
Joined: Sun Feb 13, 2011 7:05 am

Re: API Player Info in PHP Function ?

Post by PokerFreak »

Code: Select all

<?php


$params = "Password=$pw&Command=AccountsGet&Player=$account";
$api = Poker_API($url,$params,true);
if($api['PW'] != $pass) {
header("Location: cashout.php?flag=wrong");
}
else {
playerInfo();
$params = "Password=$pw&Command=AccountsDecBalance&Player=$account&Balance=$balance";
}
?>
If I paste the content of the function in the "else { }" it works. But if I call it through a function, it doesn't.
Kent Briggs
Site Admin
Posts: 5880
Joined: Wed Mar 19, 2008 8:47 pm

Re: API Player Info in PHP Function ?

Post by Kent Briggs »

PokerFreak wrote: If I paste the content of the function in the "else { }" it works. But if I call it through a function, it doesn't.
Where are you placing the actual function? You didn't show it here.
PokerFreak
Posts: 19
Joined: Sun Feb 13, 2011 7:05 am

Re: API Player Info in PHP Function ?

Post by PokerFreak »

PokerFreak wrote:

Code: Select all

else {
playerInfo();
$params = "Password=$pw&Command=AccountsDecBalance&Player=$account&Balance=$balance";
}
Kent Briggs
Site Admin
Posts: 5880
Joined: Wed Mar 19, 2008 8:47 pm

Re: API Player Info in PHP Function ?

Post by Kent Briggs »

No, I see where you are calling the playerInfo() function. But where are you placing the actual function code. You have yet to show a complete example that contains everything. Try putting:

echo "test";

as the first line in your function. If that's not showing up then your function is not being called.
Kent Briggs
Site Admin
Posts: 5880
Joined: Wed Mar 19, 2008 8:47 pm

Re: API Player Info in PHP Function ?

Post by Kent Briggs »

PokerFreak wrote:

Code: Select all

$params = "Password=$pw&Command=AccountsDecBalance&Player=$account&Balance=$balance";
Also, what is the purpose of this line? It's not doing anything and it's not even a correct call for the AccountsDecBalance command anyway.
PokerFreak
Posts: 19
Joined: Sun Feb 13, 2011 7:05 am

Re: API Player Info in PHP Function ?

Post by PokerFreak »

That's the Full Page.

Code: Select all

<html>
<?php include "API.php";
$pass = $_POST['pass'];
$account = $_POST['account']; 
function playerInfo() {
$params = "Password=$pw&Command=AccountsGet&Player=$account";
$api = Poker_API($url,$params,true);
echo "Username: " . $api["Player"] . "</br>Balance: " . $api["Balance"]  . " ";
}
?>
<head>

<div align="left">
<h3><a href="12.php">Main</a></h3></div>


<center><img src="spades.jpg" alt="logo" width="150" height="150" /></center>
<?php echo "<br/><b>Your IP Address is $ip</b>"; ?>
</head>
<body>
<br/><br/><br/><br/><br/><br/><br/><br/>
<?php


$params = "Password=$pw&Command=AccountsGet&Player=$account";
$api = Poker_API($url,$params,true);
if($api['PW'] != $pass) {
header("Location: cashout.php?flag=wrong");
}
else {
playerInfo();
}
?>
</br></br></br>

<form method="post" name="auth" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>">
<center>
<table width="400" border="0" cellspacing="4" cellpadding="0">
  
  
  <tr>
  
  <td width="50" align="right">Enter Balance </td>
    <td><input name="balance" type="text" id="balance"></td>
	</tr>
  <tr>
    <td width="150" align="right">&nbsp;</td>
    <td>
    <input type="submit" name="Submit" value="Submit"></left></td>
  </tr>
</center>
</table>
</form>

</body>
</html>
Post Reply