Jump to content
MakeWebGames

Help Needed with Loan Officer


Mark F
 Share

Recommended Posts

My loan officer page is displaying as a white page for some reason. Does anyone know why this would be? I am using MC-Codes v2.0

<?php
session_start();
require "globals.php";
print "<h3>Loan Officer</h3>


Welcome to the Loan Officer!";
if($ir['level']>=10 || $ir['user_level'] == 1)
{
if($ir['loan_days'] == $ir['loan_days_max'])
{
print "You have had your bank account frozen. and you have lost your house.

From now on until your loan balance is paid fully you will not recieve any money for your efforts.";
$db->query("UPDATE users SET bank_frozen=1,lose_house=1 WHERE userid=$userid");
exit;
}
else
{	
switch($_GET['action'])
{
case "deposit":
deposit();
break;

case "withdraw":
withdraw();
break;

default:
index();
break;
}

function index()
{
global $ir,$db,$userid,$h;
$loanleft = $ir['maxloan']-$ir['loan']+$ir['loanintrest'];
print "\n[b]Your maxloan is \${$ir['maxloan']}. Your current loan is \${$ir['loan']}.[/b]

At the end of each day, 10% of your loan amount will be taken away from your on-hand cash until you repay your loan.

<table width='75%' border='2'> <tr> <td width='50%'>[b]Pay Back Money[/b]

<form action='loanofficer.php?action=deposit' method='post'>
Amount: <input type='text' name='deposit' value='{$ir['loan']}' />

<input type='submit' value='Pay Back' /></form></td> <td>
[b]Take money[/b]

<form action='loanofficer.php?action=withdraw' method='post'>
Amount: <input type='text' name='withdraw' value='$loanleft' />

<input type='submit' value='Take Out' /></form></td> </tr> </table>";
}

function deposit()
{
global $ir,$db,$userid,$h;
$_POST['deposit']=abs((int) $_POST['deposit']);
if($_POST['deposit'] > $ir['money'])
{
print "You do not have enough money to deposit this amount.";
}
else
{
$gain=$_POST['deposit'];
$ir['loan']-=$gain;
mysql_query("UPDATE users SET loan=loan-$gain, money=money-{$_POST['deposit']} where userid=$userid",$db);
print "You hand over \${$_POST['deposit']} to be paid for your loan, 

[b]You now have a loan of \${$ir['loan']} taken out.[/b]

[url='loanofficer.php']> Back[/url]";
}
}
function withdraw()
{
global $ir,$db,$userid,$h;
$_POST['withdraw']=abs((int) $_POST['withdraw']);
$loanleftstill = $ir['maxloan'] - $ir['loan'];
if($_POST['withdraw'] > $loanleftstill)
{
print "You don't have enough money left in your max loan to withdraw this amount, choose a different amount or upgrade your max loan.";
}
else
{

$gain=$_POST['withdraw'];
$ir['loan']+=$gain;
mysql_query("UPDATE users SET loan=loan+$gain, money=money+$gain where userid=$userid",$db);
print "You ask for and get a loan of $gain, 

[b]You now have a loan of \${$ir['loan']} taken out.[/b]

[url='loanofficer.php']> Back[/url]";
}
$h->endpage();
?>
Link to comment
Share on other sites

Guest Anonymous

Re: Help Needed with Loan Officer

Add in your .htaccess

php_flag display_errors on

Should bring up a error on the page.

Link to comment
Share on other sites

Re: Help Needed with Loan Officer

Umm I'm not too sure, but you've missed out quite a few {'s or }'s.

So below, I've done what I think may work

Please Note: This is not tested, and the { or } may be added in the wrong place ['b]

 

<?php
require "globals.php";
print "<h3>Loan Officer</h3>


Welcome to the Loan Officer!";
if($ir['level']>=10 || $ir['user_level'] == 1)
{
if($ir['loan_days'] == $ir['loan_days_max'])
{
print "You have had your bank account frozen. and you have lost your house.

From now on until your loan balance is paid fully you will not recieve any money for your efforts.";
$db->query("UPDATE users SET bank_frozen=1,lose_house=1 WHERE userid=$userid");
exit;
}
}
else
{	
switch($_GET['action'])
{
case "deposit":
deposit();
break;

case "withdraw":
withdraw();
break;

default:
index();
break;
}

function index()
{
global $ir,$db,$userid,$h;
$loanleft = $ir['maxloan']-$ir['loan']+$ir['loanintrest'];
print "\n[b]Your maxloan is \${$ir['maxloan']}. Your current loan is \${$ir['loan']}.[/b]

At the end of each day, 10% of your loan amount will be taken away from your on-hand cash until you repay your loan.

<table width='75%' border='2'> <tr> <td width='50%'>[b]Pay Back Money[/b]

<form action='loanofficer.php?action=deposit' method='post'>
Amount: <input type='text' name='deposit' value='{$ir['loan']}' />

<input type='submit' value='Pay Back' /></form></td> <td>
[b]Take money[/b]

<form action='loanofficer.php?action=withdraw' method='post'>
Amount: <input type='text' name='withdraw' value='$loanleft' />

<input type='submit' value='Take Out' /></form></td> </tr> </table>";
}

function deposit()
{
global $ir,$db,$userid,$h;
$_POST['deposit']=abs((int) $_POST['deposit']);
if($_POST['deposit'] > $ir['money'])
{
print "You do not have enough money to deposit this amount.";
}
else
{
$gain=$_POST['deposit'];
$ir['loan']-=$gain;
mysql_query("UPDATE users SET loan=loan-$gain, money=money-{$_POST['deposit']} where userid=$userid",$db);
print "You hand over \${$_POST['deposit']} to be paid for your loan, 

[b]You now have a loan of \${$ir['loan']} taken out.[/b]

[url='loanofficer.php']> Back[/url]";
}
}
function withdraw()
{
global $ir,$db,$userid,$h;
$_POST['withdraw']=abs((int) $_POST['withdraw']);
$loanleftstill = $ir['maxloan'] - $ir['loan'];
if($_POST['withdraw'] > $loanleftstill)
{
print "You don't have enough money left in your max loan to withdraw this amount, choose a different amount or upgrade your max loan.";
}
else
{

$gain=$_POST['withdraw'];
$ir['loan']+=$gain;
mysql_query("UPDATE users SET loan=loan+$gain, money=money+$gain where userid=$userid",$db);
print "You ask for and get a loan of $gain, 

[b]You now have a loan of \${$ir['loan']} taken out.[/b]

[url='loanofficer.php']> Back[/url]";
}
}
}
$h->endpage();
?>
Link to comment
Share on other sites

Re: Help Needed with Loan Officer

 

Umm I'm not too sure, but you've missed out quite a few {'s or }'s.

So below, I've done what I think may work

Please Note: This is not tested, and the { or } may be added in the wrong place ['b]

 

<?php
require "globals.php";
print "<h3>Loan Officer</h3>


Welcome to the Loan Officer!";
if($ir['level']>=10 || $ir['user_level'] == 1)
{
if($ir['loan_days'] == $ir['loan_days_max'])
{
print "You have had your bank account frozen. and you have lost your house.

From now on until your loan balance is paid fully you will not recieve any money for your efforts.";
$db->query("UPDATE users SET bank_frozen=1,lose_house=1 WHERE userid=$userid");
exit;
}
}
else
{	
switch($_GET['action'])
{
case "deposit":
deposit();
break;

case "withdraw":
withdraw();
break;

default:
index();
break;
}

function index()
{
global $ir,$db,$userid,$h;
$loanleft = $ir['maxloan']-$ir['loan']+$ir['loanintrest'];
print "\n[b]Your maxloan is \${$ir['maxloan']}. Your current loan is \${$ir['loan']}.[/b]

At the end of each day, 10% of your loan amount will be taken away from your on-hand cash until you repay your loan.

<table width='75%' border='2'> <tr> <td width='50%'>[b]Pay Back Money[/b]

<form action='loanofficer.php?action=deposit' method='post'>
Amount: <input type='text' name='deposit' value='{$ir['loan']}' />

<input type='submit' value='Pay Back' /></form></td> <td>
[b]Take money[/b]

<form action='loanofficer.php?action=withdraw' method='post'>
Amount: <input type='text' name='withdraw' value='$loanleft' />

<input type='submit' value='Take Out' /></form></td> </tr> </table>";
}

function deposit()
{
global $ir,$db,$userid,$h;
$_POST['deposit']=abs((int) $_POST['deposit']);
if($_POST['deposit'] > $ir['money'])
{
print "You do not have enough money to deposit this amount.";
}
else
{
$gain=$_POST['deposit'];
$ir['loan']-=$gain;
mysql_query("UPDATE users SET loan=loan-$gain, money=money-{$_POST['deposit']} where userid=$userid",$db);
print "You hand over \${$_POST['deposit']} to be paid for your loan, 

[b]You now have a loan of \${$ir['loan']} taken out.[/b]

[url='loanofficer.php']> Back[/url]";
}
}
function withdraw()
{
global $ir,$db,$userid,$h;
$_POST['withdraw']=abs((int) $_POST['withdraw']);
$loanleftstill = $ir['maxloan'] - $ir['loan'];
if($_POST['withdraw'] > $loanleftstill)
{
print "You don't have enough money left in your max loan to withdraw this amount, choose a different amount or upgrade your max loan.";
}
else
{

$gain=$_POST['withdraw'];
$ir['loan']+=$gain;
mysql_query("UPDATE users SET loan=loan+$gain, money=money+$gain where userid=$userid",$db);
print "You ask for and get a loan of $gain, 

[b]You now have a loan of \${$ir['loan']} taken out.[/b]

[url='loanofficer.php']> Back[/url]";
}
}
}
$h->endpage();
?>

 

It no longer displays up as a blank page, though it is still not working, thanks anyhow.

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

 Share

×
×
  • Create New...