Jump to content

[SOLVED] Help with PHP Code


JCF22Lyoko

Recommended Posts

Hey guys!

 

Can someone help me fix this up?  It's supposed to take away 100,000,000 mesos from the table characters and its supposed to add 30,000 to the nxCash row in the accounts table.  So far, I can only get it to take away the mesos but when I go to the accounts table, the nxCash row stays the same.  Any help would be greatly appreciated!  :D

 

<?php
// process the script only if the form has been submitted
if (array_key_exists('reset', $_POST)) {
  // start the session
  include('functions\config2.php'); // Change config2.php to the name of your config.php if u want
  $username = trim($_POST['username']);
  $password = trim($_POST['password']);
  $username = mysql_real_escape_string($username);
  $char = trim($_POST['char']);
  $mesocheck = mysql_query('SELECT * FROM meso FROM characters');
  $result = mysql_query("SELECT meso, accountid FROM characters WHERE name = '$char' LIMIT 1");
  list($meso, $accountid) = mysql_fetch_row($result);

  $result = mysql_query("SELECT id, password, salt FROM accounts WHERE name = '$username' LIMIT 1");
  list($id, $realpass, $salt) = mysql_fetch_row($result);

  $sql = "SELECT * FROM accounts WHERE name = '$username'";
  $result = mysql_query($sql);
  $row = mysql_fetch_assoc($result);
    
if($realpass == hash('sha512',$password.$salt) && $accountid == $id && $meso >= 100000000 && $loggedin < 1) {
     mysql_query("UPDATE accounts SET nxcash = nxcash + 30000 WHERE name = '$username' LIMIT 1");
     mysql_query("UPDATE characters SET meso = meso - 100000000 WHERE name = '$char' LIMIT 1");
     echo "Success!  You have payed 100 mil from $char to get 30k NX for $username !";
} else
     echo "There was an error getting you NX. Either 1. You do not have enough money.  2. You do not have the char you listed on that account. 3.  You are logged in.";    }
  // if no match, destroy the session and prepare error message
  else {
    $message[] = 'Please Type Your Info Correctly.';
    }
?>

<!-- start content -->
       <div align="center"> <div class='welcome'><br>Welcome to the NX Cash Shop!</br>
<br>100,000,000 mesos for 30,000 NX!</br> 
<br>Make sure you are logged off during this process!</br> 
<br>No refunds for your silly mistakes!</br></div> </div><br><br>
          <div align="center">
          <div class="display">
<?php
if (isset($message)) {
  echo '<ul>';
  foreach ($message as $item) {
    echo "<li>$item</li>";
    }
  echo '</ul>';
  }
?>
           </div>
              <form id="form1" name="form1" method="post" action="">
                    <table cellspacing="0" cellpadding="5" width="100%">
                  <tr>
                            <td width="50%" align="right" class="list">Username :</td>
                          <td class="list"><input id="username" type="text" name="username" maxlength="12"></td>
                        </tr>
                        <tr>
                          <td width="50%" align="right" class="list">Password :</td>
                          <td class="list"><input id="password" type="password" name="password" maxlength="20" /></td>
                        </tr>
                        <tr>
                            <td width="50%" align="right" class="list">Character paying 100 mil :</td>
                          <td class="list"><input id="char" type="text" name="char" maxlength="12"></td>
                        </tr>
                        <tr>
                          <td align="right" colspan="2"><input id="reset" name="reset" type="submit" value="Buy 30k NX!" /></td>
                        </tr>
                    </table>
            </form>
            </div>
<!-- end content -->
</div>

Link to comment
https://forums.phpfreaks.com/topic/111564-solved-help-with-php-code/
Share on other sites

Archived

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

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