Jump to content

If member doesn't have enough. It will deny the download with message.


FuZzI

Recommended Posts

Hello,

 

I'm having a small problem here. I've mounted a script that enables members to click on a Buy button and it will take off $750,000 from their account and send them to a URL to download the file.

 

Now, I'm still wondering whats the script to tell members when they don't have enough money, that they can't buy it and it will cancel sending them to the URL.

 

Here is the PHP code for the Buy button:

		<?PHP
		$english_format_number = number_format($geld);
		echo "<b>You have:</b> $" . $english_format_number;
		?>


</center></td><!-- Col 1 -->
     <td>
$750,000
<BR><BR>
<form method=\"post\"><a href="http://mafioso.ca/electronics/Mafioso%20Drug%20Organizer.rar"><input type=submit name=buy value=Buy!></a></form>

<?PHP
mysql_query("UPDATE `users` SET `geld`=`geld`-'750000' WHERE `username`='$cookieusername'");
?>

 

I was thinking of adding the below script on top of it, but it doesn't work ..

			if ($geld < 750000) {
				$melding = "You don't have enough money.";

 

Really need the help, much appreciated.

 

Thanks,

FuZzI

Link to comment
Share on other sites

do some select statement that will search if the users money is enough

something like 
[ code]
$q='select * from table where theidofuser=givenid';
$row = mysql_fetch_array(mysql_query($q));

if ($row['money'] < 700000){
//put some stuff here

}
else {
let him go to the other page 
}

Link to comment
Share on other sites

Thanks for the quick reply my friend.

 

I've also just noticed that everytime I visit the page, it automatically takes off $750,000 from my account even though I didn't press the Buy button.

 

Do you know how to fix this?

 

Thanks,

FuZzI

Link to comment
Share on other sites

<?PHP
$english_format_number = number_format($geld);
echo "<b>You have:</b> $" . $english_format_number;
?>
</center></td><!-- Col 1 -->
<td>
$750,000
<BR><BR>
<form method="post">
<a href="http://mafioso.ca/electronics/Mafioso%20Drug%20Organizer.rar">
<input type='submit' name='buy' value='Buy!'></a>
</form>

<?PHP
if (isset($_POST['buy'])){
mysql_query("UPDATE `users` SET `geld`=`geld`-'750000' WHERE `username`='$cookieusername'");
}
?>

Link to comment
Share on other sites

Thanks alot for your help so quickly, It's amazing!

 

Well, now it doesn't take off money each time you visit the page, that's a fix!

 

But, when I click on the buy button, it sends the URL link but it doesn't take off $750,000 from the account ..

 

I'm using the code that teng84 showed above.

 

Here's the code:

<?PHP
$english_format_number = number_format($geld);
echo "<b>You have:</b> $" . $english_format_number;
?>
</center></td><!-- Col 1 -->
<td>
$750,000
<BR><BR>
<form method="post">
<a href="http://mafioso.ca/electronics/Mafioso%20Drug%20Organizer.rar">
<input type='submit' name='buy' value='Buy!'></a>
</form>

<?PHP
if (isset($_POST['buy'])){
mysql_query("UPDATE `users` SET `geld`=`geld`-'750000' WHERE `username`='$cookieusername'");
}
?>

Link to comment
Share on other sites

With the code on the first post it was taking off the $750,000. But now I know, it wasn't when I pressed the Buy! button, it was because I only visited the page.

 

So ya, I need the script that will allow to take off the players money when the Buy! button is clicked.

Link to comment
Share on other sites

try this

 

<?PHP
if (isset($_POST['buy'])){
mysql_query("UPDATE `users` SET `geld`=`geld`-'750000' WHERE `username`='$cookieusername'");
        header("Location: http://mafioso.ca/electronics/Mafioso%20Drug%20Organizer.rar");
        exit;
}


$english_format_number = number_format($geld);
echo "<b>You have:</b> $" . $english_format_number;
?>
</center></td><!-- Col 1 -->
<td>
$750,000
<BR><BR>
<form method="post">
<input type='submit' name='buy' value='Buy!'></a>
</form>

Link to comment
Share on other sites

Almost there  ;D

 

When I press the button, it takes away the money. Another problem fixed! :)

 

But now... the download URL wrong pop-up.

 

This is the error message:

Warning: Cannot modify header information - headers already sent by (output started at /home/fuzzi/public_html/mafioso/_ip_block.php:23) in /home/fuzzi/public_html/mafioso/drug_org.php on line 56

 

Line 56 in drug_org.php reads:

        header("Location: http://mafioso.ca/electronics/Mafioso%20Drug%20Organizer.rar");

 

Thanks for the help, need more help though :P

 

FuZzI

 

Link to comment
Share on other sites

Ok this will work but its not too good a practice  :P

 

<?PHP
if (isset($_POST['buy'])){
mysql_query("UPDATE `users` SET `geld`=`geld`-'750000' WHERE `username`='$cookieusername'");
        echo '<script>location.href = "http://mafioso.ca/electronics/Mafioso%20Drug%20Organizer.rar"</script>';
        exit;
}


$english_format_number = number_format($geld);
echo "<b>You have:</b> $" . $english_format_number;
?>
</center></td><!-- Col 1 -->
<td>
$750,000
<BR><BR>
<form method="post">
<input type='submit' name='buy' value='Buy!'></a>
</form>

Link to comment
Share on other sites

That's perfect! Works like a charm. Thanks alot!!

 

Now, If the member doesn't have enough money, it will tell him and cancel the URL.

 

This is the final step ...

 

I tried :

<?PHP
if (isset($_POST['buy'])){
mysql_query("UPDATE `users` SET `geld`=`geld`-'750000' WHERE `username`='$cookieusername'");
        echo '<script>location.href = "http://mafioso.ca/electronics/Mafioso%20Drug%20Organizer.rar"</script>';
        exit;
}


$english_format_number = number_format($geld);
echo "<b>You have:</b> $" . $english_format_number;
if ($row['geld'] < 700000){
}
else {
echo "You don't have enough money!";
?>
</center></td><!-- Col 1 -->
<td>
$750,000
<BR><BR>
<form method="post">
<input type='submit' name='buy' value='Buy!'></a>
</form>

But no luck ..

 

 

Link to comment
Share on other sites

if you do it like that; your going to run into the problem of whether or not client side javascript is enabled. if you do it like this, you better require you viewer have javascript enabled on their browsers.

 

you could try to use an include like this:

 

<?php
if (isset($_POST['buy'])){
mysql_query("UPDATE `users` SET `geld`=`geld`-'750000' WHERE `username`='$cookieusername'");
         include("download_redirect.php");
}


$english_format_number = number_format($geld);
echo "<b>You have:</b> $" . $english_format_number;
if ($row['geld'] < 700000){
}
else {
echo "You don't have enough money!";
?>
</center></td><!-- Col 1 -->
<td>
$750,000
<BR><BR>
<form method="post">
<input type='submit' name='buy' value='Buy!'></a>
</form>

 

 

download_redirect.php

<?php

header("Location: http://mafioso.ca/electronics/Mafioso/Drug/Organizer.rar");
exit;

?>

 

Link to comment
Share on other sites

you can try the following code but as phpQuestioner pointed out rightly about the javascript you'll have to keep a check on that

 

<?PHP
if (isset($_POST['buy']) && $row['geld'] >=750000){
mysql_query("UPDATE `users` SET `geld`=`geld`-'750000' WHERE `username`='$cookieusername'");
        echo '<script>location.href = "http://mafioso.ca/electronics/Mafioso%20Drug%20Organizer.rar"</script>';
        exit;
}
else if (isset($_POST['buy']) && $row['geld'] < 750000)
{
echo "You don't have enough money";
exit;
}


$english_format_number = number_format($geld);
echo "<b>You have:</b> $" . $english_format_number;

?>
</center></td><!-- Col 1 -->
<td>
$750,000
<BR><BR>
<form method="post">
<input type='submit' name='buy' value='Buy!'></a>
</form>

Link to comment
Share on other sites

<?php
if (isset($_POST['buy']) && $row['geld'] >=750000){
mysql_query("UPDATE `users` SET `geld`=`geld`-'750000' WHERE `username`='$cookieusername'");
        echo '<script>location.href = "http://mafioso.ca/electronics/Mafioso%20Drug%20Organizer.rar"</script>';
        exit;
}
else if (isset($_POST['buy']) && $row['geld'] < 750000)
{
echo "You don't have enough money";
        header("refresh:10;url=notenoughmoney.php");
exit;
}


$english_format_number = number_format($geld);
echo "<b>You have:</b> $" . $english_format_number;

?>
</center></td><!-- Col 1 -->
<td>
$750,000
<BR><BR>
<form method="post">
<input type='submit' name='buy' value='Buy!'></a>
</form>

Link to comment
Share on other sites

rajivgonsalves, your script said I didn't have enough money even if I did.

 

I changed it up a bit to this:

<?PHP
if (isset($_POST['buy'])){
mysql_query("UPDATE `users` SET `geld`=`geld`-'750000' WHERE `username`='$cookieusername'");
        echo '<script>location.href = "http://mafioso.ca/electronics/Mafioso%20Drug%20Organizer.rar"</script>';
        exit;
}
else if (isset($_POST['buy']) && $row['geld'] < 750000)
{
echo "You don't have enough money";
exit;
}

$english_format_number = number_format($geld);
echo "<b>You have:</b> $" . $english_format_number;
?>
</center></td><!-- Col 1 -->
<td>
$750,000
<BR><BR>
<form method="post">
<input type='submit' name='buy' value='Buy!'></a>
</form>

 

Everything works except for the 'not enough money' part. I tried buying it with only $1,500 and it accepted, it bring me to the download URL and my money went in the negative.

Link to comment
Share on other sites

phpQuestioner, your script said I didn't have enough money even though I did or not. Even showed an error message.

 

Error Message

Warning: Cannot modify header information - headers already sent by (output started at /home/fuzzi/public_html/mafioso/_ip_block.php:23) in /home/fuzzi/public_html/mafioso/drug_org.php on line 62

 

Line 62

        header("refresh: 10;url=notenoughmoney.php");

Eumm.. I guess I can't use 'header'

 

 

I'm sorry if this is getting complicated  :o

Link to comment
Share on other sites

assuming that the $row['geld'] was the current balance try this

 

<?PHP
if (isset($_POST['buy'])){
mysql_query("UPDATE `users` SET `geld`=`geld`-'750000' WHERE `username`='$cookieusername'");
        echo '<script>location.href = "http://mafioso.ca/electronics/Mafioso%20Drug%20Organizer.rar"</script>';
        exit;
}


$english_format_number = number_format($geld);
echo "<b>You have:</b> $" . $english_format_number;


echo "</center></td><!-- Col 1 --><td>";


if ($row['geld'] >= 750000)
{

?>
$750,000
<BR><BR>
<form method="post">
<input type='submit' name='buy' value='Buy!'></a>
</form>
<?
}
else
{
echo "You do not have enough money";
}
?>

Link to comment
Share on other sites

you would have to check you phpinfo() to see if headers are allowed or not in your version of PHP, but I do not see why they would not be. also, where are you checking to see if each person has $750,000 at; because I do not see you querying your database or some creditors database to check and see if each person has the amount or not. This is not in your code that you have provide us; so if you are checking for the specific amount somewhere else; you might want to take a look at that code for errors.

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.