christmas raffle system

Hello Everyone,

I’m new to php and we wanted to have a raffle system for the Christmas party. I found a system and modified to my needs, but I cant make it work. any ideas.

raffle page
[php]

Christmas Party Raffle .raffle{width:300px; margin:60px auto; text-align:center} #roll{height:32px; line-height:32px; margin-bottom:10px; font-size:24px; color:#f30} #stop{display:yes} #result{margin-top:20px; line-height:24px; font-size:16px; text-align:center}

[/php]

data.php
[php]<?php include_once('connect.php'); //connect db ?>

<?php $action = $_GET['action']; if($action==""){ //read date, return json $query = mysql_query("select * from employees where status=0"); while($row=mysql_fetch_array($query)){ $arr[] = array( 'id' => $row['id'], 'name' => $row['name'], ); } echo json_encode($arr); }else{ //Identification winning name $id = $_POST['id']; $sql = "update employees set status=1 where id=$id"; $query = mysql_query($sql); if($query){ echo '1'; } } ?>[/php]

mysql table
[php]CREATE TABLE employees (
id int(11) NOT NULL auto_increment,
name varchar(20) NOT NULL,
status tinyint(1) NOT NULL default ‘0’,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; [/php]

This code is junk. It is obsolete and insecure and vulnerable to an SQL Injection Attack. You can’t just grab code willy nilly off the internet. If you run this code, just sit back and be prepared to be hacked.

What is the goal of this raffle system?

The goal of the system is to select random employees during the Christmas party for them to receive gifts at the party. Basically I the name to appear on a field changing for 30 secs or so and not just select a random name and that’s it. once a name is selected change selected change the status to 1 from 0, so that name is unable to be query again and the same person can’t win more than once. I’m not to worry regarding sql injection attacks since this is going to be on an offline laptop on a xampp server for the party only. any suggestions?

Suggestions? Have everybody put their name in a hat. :smiley:

That’s the probably the easiest coding advice you gave this year…LOL :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service