Jump to content

I'm getting 1 where the username should be


Spring

Recommended Posts

Here's the class

 

<?php
session_start();

class Train
{
    private $_clicked;
    private $_name;
    
    
    function __construct()
    {
      $this->_name = (string) $_SESSION['nrpgusername'];
      $this->_clicked = (int) $_SESSION['clicked'];     
    }
    
    public function CheckLogged()
    {
        if(isset($this->_name))
         {}
        else{die("you must be logged in!");}
        
    }
    
    public function CheckClicked()
    {
        if(isset($_POST['go']))
        {
            $this->MysqlUpdate();
            $this->_clicked = 1;
            session_set_cookie_params(84600);
        }
       
        
    }
    
    public function Clicked()
    {
       
       if(isset($this->_clicked))
       {   echo'
            <div id="train"><img src="images/train.jpg" alt="train image"/></div> 
             <div id="text">
              <span id="click">' . $this->_name. ' has gained 7 experience,<br /> and cannot train anymore today.         </span><form method ="post" name="train" action=""> </div>'; 

       }
       
       else
        {
          echo'
           <div id="train"><img src="images/train.jpg" alt="train image"/></div> 
            <div id="text"><span id="click">Click here to train your shinobi!</span>
             <form method ="post" name="train" action=""><input type="submit" name="go" value="train"  /></div>';}

        }

    
    private function MysqlUpdate()
    {
      include("database.php");
      $query = "UPDATE account_info SET experience = experience + 7 WHERE username = '$this->name'"; 
      $result = mysql_query($query) or die(mysql_error());
    }


}


?>

 

For some reason, it's showing 1 has gained 7 experience,

and cannot train anymore today.

Instead of Tony has gained 7 experience,

and cannot train anymore today.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.