<html>
<head>
    <title>Spin Wheel</title>
    <link rel="stylesheet" href="main.css" type="text/css" />
    <script type="text/javascript" src="js/Winwheel.js"></script>
    <script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js"></script>
</head>
<body>

<?php
session_start();
include("db.php");
include("header.php");
$user_id='0';
$myip=$_SERVER['REMOTE_ADDR'];
$sql=mysqli_query($conn,"SELECT * FROM `user` WHERE ip='myip'");

$result=mysqli_num_rows($sql);
if($result > 0){
    while( $row=mysqli_fetch_object($sql)){
        $ip=$row->ip;
        $user_id=$row->$user_id;
         $_SESSION['user']=$user_id;
    }
 }
else{
 mysqli_query($conn,"INSERT INTO `user`(`ip`, `status`) VALUES ('$myip', '0')");
      $user_id = $conn->insert_id;
       $_SESSION['user']=$user_id;
}

//  while( $row=mysqli_fetch_object($sql)){
//     $ip=$row->ip;
//     $user_id=$row->$user_id;





// if($ip == $myip and $row->status=='0'){
// include("alert.php");
// }
// if($myip != $ip){
  
//    mysqli_query($conn,"INSERT INTO `user`(`ip`, `status`) VALUES ('$myip', '0')");
//  }
//  else {
//     $_SESSION['status']='1';
//  }
// }
?>
        <div align="center">
            
            <table cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td>
                    <div class="power_controls">
                        <br />
                        <br />
                        <table class="power" cellpadding="10" cellspacing="0">
                            <tr>
                                <th align="center">Power</th>
                            </tr>
                            <tr>
                                <td width="78" align="center" id="pw3" onClick="powerSelected(3);">High</td>
                            </tr>
                            <tr>
                                <td align="center" id="pw2" onClick="powerSelected(2);">Med</td>
                            </tr>
                            <tr>
                                <td align="center" id="pw1" onClick="powerSelected(1);">Low</td>
                            </tr>
                        </table>
                        <br />
                        <img id="spin_button" src="spin_off.png" alt="Spin" onClick="startSpin();" />
                        <br /><br />
                        &nbsp;&nbsp;<a href="#" onClick="resetWheel(); return false;">Play Again</a><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(reset)
                    </div>
                </td>
                <td width="438" height="582" class="the_wheel" align="center" valign="center">
                    <canvas id="canvas" width="434" height="434">
                        <p style="color: white" align="center">Sorry, your browser doesn't support canvas. Please try another.</p>
                    </canvas>
                </td>
            </tr>
        </table>
    </div>
       <?php include("footer.php"); ?>