Jump to content

Mysql execute help


marklarah

Recommended Posts

Sounds n00bish but wait...

 

So im making a slot machine for some forums, with its online currency, and they win according to the outcome. I programmed it in javascript (i know no javascript whatsoever, but its almost the same as php save a few things, but its easy)

 

Anyway, the rest is in php, and the currency is in a mysql table. The slot machine works fine, as it should. But heres the bit for winning;

 

if (r1 == r2 && r2 == r3)
{
document.slots.show.value = "JACKPOT!!!! 2000 CHIPS!!! W00T W00T W00T!!!";
alert("JACKPOT!!!! 2000 CHIPS!!! W00T W00T W00T!!!")
<?
mysql_query("UPDATE users SET chips = chips+2000 WHERE userid = '$useridm'") or die(mysql_error());
?>
window.location = "http://boards.ammostar.net/casino.php?action=slot";

}else if (r1 == r3 && r1 != r2){
document.slots.show.value = "You won 150 chips!";
alert("You won 150 chips!")
<?
mysql_query("UPDATE users SET chips = chips+150 WHERE userid = '$useridm'") or die(mysql_error());
?>
window.location = "http://boards.ammostar.net/casino.php?action=slot&win=";

}else{
document.slots.show.value = "Sorreh, you didn't win anything. Better luck next time ";
alert("Sorreh, you didn't win anything. Better luck next time ")
window.location = "http://boards.ammostar.net/casino.php?action=slot";
}

 

So guess what? I lost, but gained 2150 chips. Isnt that nice? :)

 

(becuase php has no way of knowing when to execute/not execute

 

Anyway, my solution would to be on the redirection, use another $_GET and move the mysql updating to the get. That would work, but then how to i make sure people dont just go on that page an give themselfs lots of chips?

 

Is there any other way?

 

Thanks

 

Mark

 

Link to comment
https://forums.phpfreaks.com/topic/99289-mysql-execute-help/
Share on other sites

1 don' bump a board

2) The currency field type is?

 

also you can't execute php after the page loads and your if statements appear to be javascript if/else commands so that php is executing even though its in a javascript if/else because in php's eyes that if/else doesn't exist yet

Link to comment
https://forums.phpfreaks.com/topic/99289-mysql-execute-help/#findComment-508590
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.