autmated login

For discussion of the Poker Mavens server module and other administration topics
Kent Briggs
Site Admin
Posts: 5880
Joined: Wed Mar 19, 2008 8:47 pm

Re: autmated login

Post by Kent Briggs »

antmar904 wrote:i just removed all white spaces and i am getting the same error.
Beats me. I just ran the same code on my local system (using EasyPHP running PHP 5.2.8) and it logged me in fine.
Kent Briggs
Site Admin
Posts: 5880
Joined: Wed Mar 19, 2008 8:47 pm

Re: autmated login

Post by Kent Briggs »

Oh wait, I just figured it out. The html and body tags are getting sent out before the header() line. Move those down like I show below. I don't know why that worked on my local system. I should have got the same error.

Code: Select all

  <?php

    $server = "http://127.0.0.1:8087";   // set your url here
    include "API.php";  // $pw and $url set in this file

    if (isset($_POST["Login"]))
    {
      $player = $_POST["Player"];
      $password = $_POST["Password"];
      $params = "Password=$pw&Command=AccountsPassword" . "&Player=" . urlencode($player) . "&PW=" . urlencode($password);
      $api = Poker_API($url,$params,true);
      if ($api["Result"] != "Ok") die($api["Error"] . "<br/>" . "Click Back Button to retry.");
      if ($api["Verified"] != "Yes") die("Password is incorrect. Click Back Button to retry.");
      $params = "Password=$pw&Command=AccountsSessionKey&Player=" . urlencode($player);
      $api = Poker_API($url,$params,true);
      if ($api["Result"] != "Ok") die($api["Error"] . "<br/>" . "Click Back Button to retry.");
      $key = $api["SessionKey"];
      header("Location:" . $server . "/?LoginName=" . $player . "&SessionKey=" . $key);
      exit;
    }
  ?>

<html>
<body>
 
  <h3>Poker Login</h3>
  <form method="post">
    <table>
      <tr>
        <td>Player Name:</td>
        <td><input type="text" name="Player"></td>
      </tr>
      <tr>
        <td>Password:</td>
        <td><input type="password" name="Password"></td>
      </tr>
      <tr>
        <th colspan="2"><input type="submit" name="Login" value="Login"></th>
      </tr>
    </table>
  </form>

</body>
</html>
antmar904
Posts: 30
Joined: Sun Oct 07, 2012 7:24 pm

Re: autmated login

Post by antmar904 »

sorry no cigar im still getting the same error.

here is the page:

http://knockpoker.net/user.php

ive tried everything should i try maybe a different port?

i am using port 80
Kent Briggs
Site Admin
Posts: 5880
Joined: Wed Mar 19, 2008 8:47 pm

Re: autmated login

Post by Kent Briggs »

If you're still getting the error about headers already sent, that has nothing to do with the port. Somehow your script is outputting text before this line is executed:

header("Location:" . $server . "/?LoginName=" . $player . "&SessionKey=" . $key);

This could also be done using javascript instead of doing a redirect with a custom header. I'll work up an example of that and post it here later today.
antmar904
Posts: 30
Joined: Sun Oct 07, 2012 7:24 pm

Re: autmated login

Post by antmar904 »

thank you i would very much appreciate that.
Kent Briggs
Site Admin
Posts: 5880
Joined: Wed Mar 19, 2008 8:47 pm

Re: autmated login

Post by Kent Briggs »

Alright, try this. Replace the header() line with this javascript:

Code: Select all

    echo("<html><body><script>");
    echo("window.location='$server/?LoginName=$player&SessionKey=$key'");
    echo("</script></body></html>");
Full code:

Code: Select all

<?php

  $server = "http://127.0.0.1:8087";   // set your url here
  include "API.php";  // $pw and $url set in this file

  if (isset($_POST["Login"]))
  {
    $player = $_POST["Player"];
    $password = $_POST["Password"];
    $params = "Password=$pw&Command=AccountsPassword" . "&Player=" . urlencode($player) . "&PW=" . urlencode($password);
    $api = Poker_API($url,$params,true);
    if ($api["Result"] != "Ok") die($api["Error"] . "<br/>" . "Click Back Button to retry.");
    if ($api["Verified"] != "Yes") die("Password is incorrect. Click Back Button to retry.");
    $params = "Password=$pw&Command=AccountsSessionKey&Player=" . urlencode($player);
    $api = Poker_API($url,$params,true);
    if ($api["Result"] != "Ok") die($api["Error"] . "<br/>" . "Click Back Button to retry.");
    $key = $api["SessionKey"];
    echo("<html><body><script>");
    echo("window.location='$server/?LoginName=$player&SessionKey=$key'");
    echo("</script></body></html>");
    exit;
  }
?>

<html>
<body>
 
  <h3>Poker Login</h3>
  <form method="post">
    <table>
      <tr>
        <td>Player Name:</td>
        <td><input type="text" name="Player"></td>
      </tr>
      <tr>
        <td>Password:</td>
        <td><input type="password" name="Password"></td>
      </tr>
      <tr>
        <th colspan="2"><input type="submit" name="Login" value="Login"></th>
      </tr>
    </table>
  </form>

</body>
</html>
antmar904
Posts: 30
Joined: Sun Oct 07, 2012 7:24 pm

Re: autmated login

Post by antmar904 »

you are a absolute genius thank you very much for your patients and time.

that worked perfect.

i am very new to php and html so thank you once again! :D :D
antmar904
Posts: 30
Joined: Sun Oct 07, 2012 7:24 pm

Re: autmated login

Post by antmar904 »

just one more question...

is it possible to redirect the user to another page where i have the poker game in a iframe instead of http://127.0.0.1:80?

exp:

the page where i put the poker game in a iframe is called play.php.

how can i check the logon credentials of the player then if passed redirect the player to play.php page logging them into the server.

thanks again for your help
Kent Briggs
Site Admin
Posts: 5880
Joined: Wed Mar 19, 2008 8:47 pm

Re: autmated login

Post by Kent Briggs »

antmar904 wrote:just one more question...
is it possible to redirect the user to another page where i have the poker game in a iframe instead of http://127.0.0.1:80?
exp:
the page where i put the poker game in a iframe is called play.php.
how can i check the logon credentials of the player then if passed redirect the player to play.php page logging them into the server.
thanks again for your help
Set the $server variable to your play.php URL. Then the script in play.php could pull the login credentials out of the URL like this:

$player = $_GET["LoginName"];
$key = $_GET["SessionKey"];

and then echo out the iframe tag on-the-fly where you set the src parameter to the poker server URL with the parameters. It would probably look something like this (untested):

echo("<iframe src='http://1.2.3.4:8087?LoginName=$player&S ... '></iframe>");
antmar904
Posts: 30
Joined: Sun Oct 07, 2012 7:24 pm

Re: autmated login

Post by antmar904 »

the i frame was working but when i put in iframe attributes (width/height) its giving me a : Unknown player: $player ERROR

i think maybe my syntax is wrong?

echo('<iframe src="http://184.82.171.17:80?LoginName=$play ... onKey=$key" width="1200" height="700"></iframe>');
Post Reply