Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Could Someone Proofread My Php Lottery Script.
coolcat50
post Oct 11 2007, 10:16 PM
Post #1


Super Member
*********

Group: Members
Posts: 290
Joined: 5-October 07
From: Random Places
Member No.: 51,171
Spam Patrol



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.

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.
Go to the top of the page
 
+Quote Post
ewcreators
post Oct 14 2007, 12:52 PM
Post #2


Member [Level 1]
****

Group: Members
Posts: 59
Joined: 28-August 07
Member No.: 48,983



QUOTE(coolcat50 @ Oct 11 2007, 06:16 PM) *
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.

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.";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):
CODE
<?php
if ($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:
CODE
<?php
$lottnum=rand(1,100);
?>

generates a number between 1 and hundred.

Hope this helps biggrin.gif
Go to the top of the page
 
+Quote Post
coolcat50
post Oct 14 2007, 06:47 PM
Post #3


Super Member
*********

Group: Members
Posts: 290
Joined: 5-October 07
From: Random Places
Member No.: 51,171
Spam Patrol



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
Go to the top of the page
 
+Quote Post
ewcreators
post Oct 15 2007, 02:42 PM
Post #4


Member [Level 1]
****

Group: Members
Posts: 59
Joined: 28-August 07
Member No.: 48,983



Post them here, im sure i can help smile.gif
Go to the top of the page
 
+Quote Post
sonesay
post Oct 15 2007, 07:10 PM
Post #5


|||[ n00b King ]|||
*********

Group: [HOSTED]
Posts: 681
Joined: 20-June 07
From: Auckland
Member No.: 45,102



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.

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
{
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.

CODE
<?php
....

else {
?>
HTML CODE

<?php
}
?>




I hope that helps

This post has been edited by sonesay: Oct 15 2007, 07:25 PM
Go to the top of the page
 
+Quote Post
galexcd
post Oct 15 2007, 07:27 PM
Post #6


Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software.
***********

Group: [HOSTED]
Posts: 1,020
Joined: 25-September 05
From: L.A.
Member No.: 12,251



QUOTE(coolcat50 @ Oct 11 2007, 03:16 PM) *
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...

QUOTE(sonesay @ Oct 15 2007, 12:10 PM) *
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
CODE
$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...

QUOTE(sonesay @ Oct 15 2007, 12:10 PM) *
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.

This post has been edited by alex7h3pr0gr4m3r: Oct 16 2007, 05:24 PM
Go to the top of the page
 
+Quote Post
coolcat50
post Oct 16 2007, 11:06 PM
Post #7


Super Member
*********

Group: Members
Posts: 290
Joined: 5-October 07
From: Random Places
Member No.: 51,171
Spam Patrol



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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Script: Php Jukebox(4)
  2. Parse: Error Unexpected T_lnumber(4)
  3. Transfer Variables To Another Php Script(8)
  4. Watermark Your Image With Simple Php Script(35)
  5. Script That Tracks The User Status(4)
  6. Wappychat_oldskool(15)
  7. Free Auction Script(6)
  8. Wappy Buddy V1.10 - Tibia Gold Edition By Wappy & Jon Roig(3)
  9. What Kind Of Script Do You Need ?(15)
  10. Creatting A Playlist Through Php(5)
  11. Is This A Good Script?(9)
  12. Html Code Tester. Online Script(15)
  13. Php Sessions And Post Variables Issues(1)
  14. Will This Code Work(5)
  15. Php Downloads Script(4)
  1. Script Help Required: Undefined Variable(3)
  2. Script Not Working(6)
  3. Library Script(6)
  4. How Would I Go About Making A Simple "counting" Script?(3)
  5. Forum Script(3)
  6. Php Rediret Script(12)
  7. Download Script For Mp3 Files(0)
  8. How Do I Connect To Live Database With Php Script?(6)
  9. Need Help Installing Dolphin Community Script!(5)
  10. Guessing Php Script(2)
  11. How To Make A View New Post Script?(5)
  12. Php Guest Online Script(3)
  13. How To Make Php Newsletter Script(3)