Page 1 of 1

i need help with my store.php

Posted: Thu Feb 21, 2013 8:27 pm
by maggnetic
help me every time i go to my store an try to buy an item it tells me that in not login this is my store.php

Code: Select all

<?php
include_once 'connect.php';
 session_start();
   include_once 'logo.php';
   ?>
     <link href="style.css" rel="stylesheet" type="text/css" />
<?php
if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
  exit;
}
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);

?>
</div>
<div id="table">
 <?php
$creature = $_GET['creature'];
$counter = 0;




 echo "<small>";
      print "<center>";
      print "<table border='0' width='70%' cellspacing='20'>";
      print "<tr><td width='25%' valign='top'>";
      print "</td>";
      print "<td valign='top' width='75%'>";
      $invinfo="SELECT * from store where amount > 0 ";
      $invinfo2=mysql_query($invinfo) or die("could not select anything from the store.");
      print "<table border='1' bordercolor='white' bgcolor='#ffffff'>";
      print "<tr><td>Name<font color='ffffff'>________________</td><td>Stat<font color='ffffff'>______</td><td>Stat Add<font color='ffffff'>______</td><td>Type<font color='ffffff'>______</td><td>Price<font color='ffffff'>______</td><td><font color='ffffff'>____________</td></tr>";
      while($invinfo3=mysql_fetch_array($invinfo2))
      {
      $counter = 1;
      print "<tr><td>$invinfo3[name]</td><td>$invinfo3[stats]</td><td>$invinfo3[statadd]</td><td>$invinfo3[type]</td><td>$invinfo3[price]</td><td><A href='buyitem.php?randid=$invinfo3[randid]'>Buy Item</td></tr>";

      }

      print "</table>";
      print "</td></tr></table>";
      print "</center>";
      echo "</small>";

      if ($counter == 0)
      {
            echo "<center>There is nothing in the store at this time.<br>";
            echo "<a href='battle.php?creature=$creature'>Go Back</center>";
            exit;
      }
  echo "<center><a href='battle.php?creature=$creature'>NeverMind</center></a>";
  
  ?>
  </div>


Re: i need help with my store.php

Posted: Thu Feb 21, 2013 9:00 pm
by Mardonis
Does this: include_once 'logo.php';

need to be this: include_once 'login.php';

Re: i need help with my store.php

Posted: Fri Feb 22, 2013 3:39 pm
by overras
session_start(); must be first defined. But , is enough to define it one time in connect.php, anyway try this:

Code: Select all

<?php
session_start();
include 'connect.php';
   include 'logo.php';
   ?>
     <link href="style.css" rel="stylesheet" type="text/css" />
<?php
if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
  exit;
}
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);

?>
</div>
<div id="table">
 <?php
$creature = $_GET['creature'];
$counter = 0;




 echo "<small>";
      print "<center>";
      print "<table border='0' width='70%' cellspacing='20'>";
      print "<tr><td width='25%' valign='top'>";
      print "</td>";
      print "<td valign='top' width='75%'>";
      $invinfo="SELECT * from store where amount > 0 ";
      $invinfo2=mysql_query($invinfo) or die("could not select anything from the store.");
      print "<table border='1' bordercolor='white' bgcolor='#ffffff'>";
      print "<tr><td>Name<font color='ffffff'>________________</td><td>Stat<font color='ffffff'>______</td><td>Stat Add<font color='ffffff'>______</td><td>Type<font color='ffffff'>______</td><td>Price<font color='ffffff'>______</td><td><font color='ffffff'>____________</td></tr>";
      while($invinfo3=mysql_fetch_array($invinfo2))
      {
      $counter = 1;
      print "<tr><td>$invinfo3[name]</td><td>$invinfo3[stats]</td><td>$invinfo3[statadd]</td><td>$invinfo3[type]</td><td>$invinfo3[price]</td><td><A href='buyitem.php?randid=$invinfo3[randid]'>Buy Item</td></tr>";

      }

      print "</table>";
      print "</td></tr></table>";
      print "</center>";
      echo "</small>";

      if ($counter == 0)
      {
            echo "<center>There is nothing in the store at this time.<br>";
            echo "<a href='battle.php?creature=$creature'>Go Back</center>";
            exit;
      }
  echo "<center><a href='battle.php?creature=$creature'>NeverMind</center></a>";
  
  ?>
  </div>

Re: i need help with my store.php

Posted: Tue Feb 26, 2013 3:22 am
by maggnetic
no its not a login its a logo

Re: i need help with my store.php

Posted: Tue Feb 26, 2013 3:25 am
by maggnetic
overras the code you gave me doesnt seem to work it does the samething

Re: i need help with my store.php

Posted: Tue Feb 26, 2013 5:55 am
by Callan S.
So are you logging in with a log in script? And that doesn't give any errors? Does that log in script have 'session_start();' at the top of it?

Re: i need help with my store.php

Posted: Tue Feb 26, 2013 2:20 pm
by Jackolantern
Have you checked to make sure that you are accessing exactly the same session variable that you set when you logged in. I did that tons of times before. $_SESSION['name'] in one, and $_SESSION['player'] in another and things like this.

Re: i need help with my store.php

Posted: Thu Feb 28, 2013 6:09 pm
by maggnetic
callan my login scipt doesnt have a session-start(), does it need to have it?

Re: i need help with my store.php

Posted: Thu Feb 28, 2013 11:02 pm
by hallsofvallhalla
yeah make sure the session variable you are setting is called player and that the previous page is not unsetting it.