Jump to content

mysql with some coding, need some help.


furielrage

Recommended Posts

<?php

// Cute way of saying don\'t hack the board

if ($mid == $userid)

{

die(\'Noone (Script Shutdown: mid = userid)\');

}

// Let\'s find out exactly who we are donating to

$DB->query("SELECT name, id FROM ibf_members WHERE id=\'".$mid."\'");

if ( ! $row = $DB->fetch_row() )

{

die(\'User does not exist\');

}

$dname = $row[\'name\'];

echo($dname);

// Print Form

?>!

 

With this code (where it queries the database) it will only select the guest id instead of the member who clicks his/her id. It\'s supposed to select the id of the person that is clicked on and change some data in the sql database, but I don\'t know how to get it to do that.

 

I haven\'t done much of this stuff so a little explanation would help very much

 

This piece of code is suppose to select the member who you clicked on to donate zeny(fake forum money) to in ibf_members. The thing is, I can\'t get it to point to the person that a member chose to donate money to.

 

Here is a shot of my ibf_members table:

table.jpg

 

If it helps, you can login to the forum and check. http://www.ffxii.org/forum

user/pass = demo/demo

 

In each user\'s post look at the left with all the rpg stats. You\'ll see \"donate zeny\" link at the bottom.

 

Here is the whole coding for the page:

 

<?php

//-----------------------------------------

//     RPG Shop 1.1 beta for IPB 1.2      

//-----------------------------------------

//     This is part of a pre-made set

//     of files created to add a shop

//     and other community related things

//     to an community bulliten board.

//     Feel free to edit to your hearts

//     content, but leave this copyright

//     at the top.

//-----------------------------------------

//     Created by: Xerin

//     Edited by: Gogeta

//     Released for IPB 1.2 by: Gogeta

//-----------------------------------------

/*     Place Your Edits Here



*/

?>

<html>

<head>

<title>Donating!</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">



</head>



<body bgcolor="#BFC4C9">

<?php

global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;

 // Check to see if the member is loged in

if ( ! $ibforums->member[\'id\'] )

{

 die(\'Please login\');

 return;

}

 // Define some nice names for varibles

  $userid = $ibforums->member[\'id\'];

  $username = $ibforums->member[\'name\'];



  $zeny = $ibforums->member[\'zeny\'];



  if ($z == 1) // We are transfering money

{

 // Begin Hack Check

  if ($donate < 100)

{

 // Anything below 100, Stop

  die(\'Please be nice and donate at least 50 zeny.\');

}



  if ($mid == \'\')

{

 // No Member ID, Stop

 die(\'No Member Selected\');

}

  if ($mid == $userid)

{

 // User is attempting to donate to self

 // Do Not Remove this Check, or everyone can

 // have unlimited zenies.

 die(\'No Way Mister Hax0r\');

}

  if ($mid <= 0)

{

 // User is attempting to donate to a guest

 // Can\'t allow this can we?

 die(\'I\'m sure guest would love it, but, no\');

}

 // End Hack Check

 // Begin Zeny Checking Amount

echo(\'Checking zeny amount.....\');

  $negz = ($zeny - $donate);

  if ($zeny < $negz)

{

 die(\' Sorry, not enough money :(\');

}

  if ($zeny < $donate)

{

 die(\'You dont have enough money :(\');

}

  if ($negz < 0)

{

 die(\'omg u h4x\');

}

 // Done

 echo(\'done<br>\');

 // Query the database and get the member we are donating to

$DB->query("SELECT name, id, zeny FROM ibf_members WHERE id=\'".$mid."\'");

if ( ! $row = $DB->fetch_row() )

{

 die(\'Please Report this Error to your Admin (Script Shutdown)\');

}

 // Begin updating accounts

 // Update our members account first

echo(\'Updating members accounts.....\'); 

$ze = "UPDATE `ibf_members` SET `zeny` = \'$negz\' WHERE `id` = \'$userid\' LIMIT 1;";

mysql_query($ze);

 // Now update the other members account

$donate2 = ($row[\'zeny\'] + $donate);

$sql = "UPDATE `ibf_members` SET `zeny` = \'$donate2\' WHERE `id` = \'". $row[\'id\'] ."\' LIMIT 1";

mysql_query($sql);

echo(\'done<br>\');

 // Done

 // Printing out a Receipt (Graphical Use Only)

echo(\'Preparing Receipt........\');

$today = date("F j, Y, g:i a"); 

echo(\'done<br>\');

echo(\'Printing Your Receipt (Please Save for Future Refernce)<br><br>\');

echo("<span id=\'code\'>");

echo(\'-------------------------------------<br>\');

echo(\'             Receipt                 <br>\');

echo(\'-------------------------------------<br>\');

echo(\'You Transfered                 \'.$donate.\'z<br>\');

echo($row[\'name\']." Recieved the amount in full.<br>");

echo(\'Your new balence is:\'.$negz.\'<br>\');

echo($row[\'name\']."\'s new balence is:".$donate2."<br>");

echo(\'Thank you for using our service!<br>\');

echo(\'-------------------------------------<br>\');

echo($today.\'<br>\');

echo(\'-------------------------------------<br>\');

echo(\'</span><br><br><br>\');

 // Done Showing the Receipt, Save it to Profile

echo(\'Saving receipt to database....\');

 // Save for Member Giving

$re = \'INSERT INTO `ibf_receipt` (`id`, `mid`, `tran`, `z`, `date`) VALUES (\'\', \'\'.$userid.\'\', \'Transfered Zeny to \'.$row[\'name\'].\'\', \'\'.$donate.\'\', \'\'.$today.\'\');\'; 

mysql_query($re);

 // Save for Member Taking

$re = \'INSERT INTO `ibf_receipt` (`id`, `mid`, `tran`, `z`, `date`) VALUES (\'\', \'\'.$row[\'name\'].\'\', \'Recieve Zeny from \'.$username.\'\', \'\'.$donate.\'\', \'\'.$today.\'\');\'; 

mysql_query($re);

 // Done

echo(\'done<br>\');

 // Thank You Come Again

echo(\'Thank You!\');

}

else // Print up a box and say please tell us how much you want to transfer

{

global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;



?>

<center>

<font face="Verdana" size="2">Hello <?php echo($username); ?>, you have  <?php echo $zeny; ?> 

to donate.<br><br>

If you choose to donate, we will be transferring your money to:

<?php

 // Cute way of saying don\'t hack the board

  if ($mid == $userid)

{

 die(\'Noone (Script Shutdown: mid = userid)\');

}

 // Let\'s find out exactly who we are donating to

$DB->query("SELECT name, id FROM ibf_members WHERE id=\'".$mid."\'");

if ( ! $row = $DB->fetch_row() )

{

 die(\'User does not exist\');

}

$dname = $row[\'name\'];

echo($dname);

 // Print Form

?>! </font>

<form name="form1" method="post" action="<?php echo $PHP_SELF; ?>?act=tran&mid=<?php echo($row[\'id\']); ?>&z=1">

<p>Amount You Wish to Donate:

  <input type="text" name="donate">

</p>

<p>

  <input type="submit" name="Submit" value="Donate!">

</p>

</form>

</center>

<?php

}



?>

img][img]

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.