Lol cool
Printable View
Lol cool
True never really thought about it, however it's very easy to change from username to id. haha:)
Oh yeah, about the $_SESSION coins; it has never happened to me that the coins stay the same it updates & just saying the user only gets 1 lottery ticket unless the whole table is emptied / winner is chosen.
Thanks for the replies everyone,
It dosnt work. Nothing shows up in the database. Please help!
To make life easier you could fully automate it by setting a cronjob.
My lottery2 shows
##->Inserting values in database $cost = '5000'; // How much each lottery ticket will cost // Grabbing the POST'ed figures $Figure_1 = mysql_real_escape_string($_POST["Figure_1"]); $Figure_2 = mysql_real_escape_string($_POST["Figure_2"]); $Figure_3 = mysql_real_escape_string($_POST["Figure_3"]); $userCoins = "" . $_SESSION['user']['credits'] . ""; // If users coins are below the lottery cost, we'll send the header as an error if($userCoins < $cost) { Header("Location: me?Error?=Balance"); } else { // Taking away the cost of lottery to the users account $coins = mysql_query("UPDATE `users` SET `credits` = credits - ". $cost ." WHERE username = '" . $_SESSION['user']['username'] . "'"); // Inserting the values into database, we'll send the header as successful $sql = mysql_query("INSERT INTO `lottery` (Username, Figure_1, Figure_2, Figure_3) VALUES ('". $_SESSION['user']['username'] ."', '". $Figure_1 . "', '". $Figure_2 . "', '". $Figure_3 .")"); Header("Location: me?successful"); }
Nice one merkleman