Time Point To Cash
#9

Its really not that hard to make it in pdo.

Also, if u want to edit that later u will spend hours on tracing back all the variables u used.

 

<?php

try
{
$db = new PDO('mysql:host=localhost', 'username', 'password');
}
catch
{
die('Unable to connect to the database<br />Please try again later');
}

if( $User->LoggedIn == true )
{

$dbauth = $SiteSQL["config-database_auth"];
$dbsite = $SiteSQL["config-database_site"];
$uid = $User->ID;

$query = sprintf
("
SELECT
u.cash as cash,
l.a_online_time as time

FROM
%s.bg_user u,
%s.t_user_log l

WHERE
u.user_code = :uid

AND
l.a_account_index = u.user_code

", $dbauth,
$dbsite );

$dbh = $db->prepare($query);

$dbh->bindParam(':uid', $uid, PDO:TongueARAM_INT);
$dbh->execute();

$result = $dbh->fetch();

$cash = $result['cash'];
$time = $result['time'];

if( isset($_POST['change']))
{

$dbh = $db->prepare( sprintf('UPDATE %s.bg_user SET cash = cash + :timepoints WHERE user_code = :uid', $auth));
$dbh->bindParam(':timepoints', $time, PDO:TongueARAM_INT);
$dbh->bindParam(':uid', $uid, PDO:TongueARAM_INT);
$dbh->execute();

$dbh = $db->prepare( sprintf('UPDATE %s.t_user_log SET a_online_time = 0 WHERE a_account_index = :uid', $db));
$dbh->bindParam(':uid', $uid, PDO:TongueARAM_INT);
$dbh->execute();

$cash -= $time;
$time = 0;

}

printf
('
<center>
Your Current Cash Is : %d<br />
Your current online time points : %d<br />

<form id="form1" name="form1" method="post">
<input name="change" value="Time For Cash !" type="submit" />
</form>
</center>

', $cash, $time);

}
else
echo 'Please login to exchange Online Time Points for Cash';

?>

 



Messages In This Thread
[No subject] - by ReturnKratos - 08-22-2012, 06:04 PM
[No subject] - by MrBeaN - 08-22-2012, 07:12 PM
[No subject] - by ReturnKratos - 08-22-2012, 07:25 PM
[No subject] - by someone - 08-23-2012, 12:20 AM
[No subject] - by Blackfire - 08-23-2012, 12:32 AM
[No subject] - by Blackfire - 08-23-2012, 12:37 AM
[No subject] - by barroso - 08-27-2012, 05:53 PM
[No subject] - by ReturnKratos - 08-27-2012, 06:24 PM
[No subject] - by Wizatek - 08-27-2012, 06:57 PM
[No subject] - by Sutz - 08-29-2012, 04:51 PM
[No subject] - by ReturnKratos - 08-29-2012, 05:08 PM
[No subject] - by Blackfire - 08-29-2012, 05:51 PM
[No subject] - by Blackfire - 08-29-2012, 06:15 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)