Jump to content
xisto Community
Sign in to follow this  
coolcat50

Could Someone Proofread My Php Lottery Script.

Recommended Posts

Ok, I have written a PHP Lottery Script that will e-mail me when someone wins the lottery. I will make it more advanced as I learn more such as use a MySQL database and automate it, but I need to start with the basic design.Here is my current code.

<?php//Add the code in body tags$lottonum="lotto_num_here";$nument="$_REQUEST['nument']";$name="$_REQUEST['name'];if ($lottonum == $nument){echo "Thank you! You have won the grand prize! An email has been sent to notify the admins.";mail("email@here.com" , "Subject: Lottery Winner $name" , "$name has just won the lottery. Please update his profile.");}else{?><form method="post"><input type="text" value="Name" name="name" /><br /><input type="text" value="#####" name="nument" /><br /><input type="submit" value="Submit" /></form><?php}?>

The script is designed to set up a form that will act like a password script and if you submit the correct number, the email is sent informing me of their winning the prize. The prize will most likely be member promotions on the forum or something like that.Also, any help on how to automate it and use a MySQL database will be greatly appreciated. Well please help with the script. Thank you.

Share this post


Link to post
Share on other sites

Ok, I have written a PHP Lottery Script that will e-mail me when someone wins the lottery. I will make it more advanced as I learn more such as use a MySQL database and automate it, but I need to start with the basic design.
Here is my current code.

$name="$_REQUEST['name'];
if ($lottonum == $nument)
{
echo "Thank you! You have won the grand prize! An email has been sent to notify the admins.";he email is sent informing me of their winning the prize. The prize will most likely be member promotions on the forum or something like that.
mail("email@here.com" , "Subject linenums:0'><?php//Add the code in body tags$lottonum="lotto_num_here";$nument="$_REQUEST['nument']";$name="$_REQUEST['name'];if ($lottonum == $nument){echo "Thank you! You have won the grand prize! An email has been sent to notify the admins.";he email is sent informing me of their winning the prize. The prize will most likely be member promotions on the forum or something like that.mail("email@here.com" , "Subject: Lottery Winner $name" , "$name has just won the lottery. Please update his profile.");}else{?><form method="post"><input type="text" value="Name" name="name" /><br /><input type="text" value="#####" name="nument" /><br /><input type="submit" value="Submit" /></form><?php}?>
The script is designed to set up a form that will act like a password script and if you submit the correct number, t

Also, any help on how to automate it and use a MySQL database will be greatly appreciated. Well please help with the script. Thank you.
Nice script...I am working on a lotto-mysql based script for my game.Anyways, when you say automate, do you mean that you want it to automatically update their profile?
Well, if your using a mysql database, then in the if($lottonum=$nument) bit, i suggest you do it like this (if you have the profiles stored in a database):
<?phpif ($lottonum==$nument) {$qry=mysql_query("UPDATE table_name SET money='money+$lotto_won_credits' WHERE name='$_POST[name]'");echo "You won ___ amount of money. Congratulations! It has been added onto your profile.";}?>

also for lottonum , to make sure they dont keep winning by entering the same number, use this random script:
<?php$lottnum=rand(1,100);?>
generates a number between 1 and hundred.

Hope this helps :P

Share this post


Link to post
Share on other sites

Hmm thanks!I will most likely use your mods. This will be going into my game now. And yeah I want it automatically update their profiles. First thing though is to get my game to work. I can't get my stats.php , register.php , or login.php files to work. I haven't even began programming the rest. LOL

Share this post


Link to post
Share on other sites

Hey Coolcat I had a look at your code and copy n pasted it to try out it has some syntax errors so it wouldnt work for me. I had to change a few things.

<?php//Add the code in body tags$lottonum="lotto_num_here";$nument = $_REQUEST['nument'];$name = $_REQUEST['name'];if ($lottonum == $nument){echo "Thank you! You have won the grand prize! An email has been sent to notify the admins.";mail("email@here.com" , "Subject: Lottery Winner $name" , "$name has just won the lottery. Please update his profile.");}else{echo "<form method=\"post\"><input type=\"text\" value=\"".$name."\" name=\"name\" /><br /><input type=\"text\" value=\"".$nument."\" name=\"nument\" /><br /><input type=\"submit\" value=\"Submit\" /></form>";}?>

I've never used $_REQUEST before but if you put qoutes around it wont work. The other thing is with the else statment I dont think you can do. When you want to print out values in PHP variables you have to use the $ sign. Its seperate from the strings and joined by . on each end.

<?php....else {?> HTML CODE<?php}?>

I hope that helps

Edited by sonesay (see edit history)

Share this post


Link to post
Share on other sites

Ok, I have written a PHP Lottery Script that will e-mail me when someone wins the lottery. I will make it more advanced as I learn more such as use a MySQL database and automate it, but I need to start with the basic design.

I don't see any checks there for multiple guesses. It looks like anybody could just guess every single number until they win. The point of a lottery is to only be allowed to guess once...

I've never used $_REQUEST before but if you put qoutes around it wont work.

variables can be put into quotes in php, but if you put an array in you must denote it with brackets
$nument="{$_REQUEST['nument']}";$name="{$_REQUEST['name']}";
But there is no real point in doing that because theres no other string you want to combign it with so I agree with sonesay... Get rid of those quotes... even if you wanted to combine strings and variables I don't suggest putting the variables right in the string. Even though it works its a bad habbit to get into. Just combine the strings with a period...

So can anyone tell me does request work like $_POST?

Request is both $_POST and $_GET together. It recieves both post and get data sent to the page. I usualy only use it when dealing with ajax because I found some browsers when doing ajax send the data via get rather than post, while others use post, and request gets em both. Otherwise I use whichever type I am expecting to receive.
Edited by alex7h3pr0gr4m3r (see edit history)

Share this post


Link to post
Share on other sites

Thanks! I think my login files are doing good and I have debugged my stats page. I manually input me into my MySQL table but can't login. i will post a link to a copy of the file later. Thanks guys. Ya'll are alot of help with my PHP problems. I am a PHP noob and can barely debug. Thanks again.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.