small bugfixes to get comments for examples comments working
[e-DoKo.git] / index.php
1 <!DOCTYPE html PUBLIC
2     "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
3     "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
5   <head>
6      <title>e-Doko</title>
7      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
8      <link rel="stylesheet" type="text/css" href="standard.css" />      
9      <script type="text/javascript">
10        function hl(num) {
11          if(document.getElementById){
12            var i;
13            for(i=1;i<13;i++){
14              if(document.getElementById("trick"+i))
15                document.getElementById("trick"+i).style.display = 'none';
16            }
17            document.getElementById("trick"+num).style.display = 'block';
18          }
19        }
20        function high_last(){
21          if(document.getElementById){
22            var i;
23            for(i=12;i>0;i--) {
24              if(document.getElementById("trick"+i))
25                {
26                  hl(i);
27                  break;
28                }
29            }
30          }
31        }
32      </script>
33   </head>
34 <body onload="high_last();">
35 <div class="header">
36 <h1> Welcome to E-Doko </h1>
37 </div>
38
39 <?php
40 error_reporting(E_ALL);
41      
42 include_once("functions.php");
43 include_once("db.php");
44
45 DB_open();
46
47 /* end header */
48
49 /*****************  M A I N **************************/
50
51 /* check if we want to start a new game */
52 if(isset($_REQUEST["new"]))
53   {
54 ?>
55     <p>Please add 4 names, please make sure that the names are correct! </p>
56        <form action="index.php" method="post">
57    Name:  <input name="PlayerA" type="text" size="10" maxlength="20" /> 
58    Name:  <input name="PlayerB" type="text" size="10" maxlength="20" /> 
59    Name:  <input name="PlayerC" type="text" size="10" maxlength="20" /> 
60    Name:  <input name="PlayerD" type="text" size="10" maxlength="20" /> 
61
62    <input type="submit" value="start game" />
63  </form>
64 <?php
65   } 
66 /* end start a new game */
67
68 /*check if everything is ready to set up a new game */
69 else if( isset($_REQUEST["PlayerA"]) && 
70     isset($_REQUEST["PlayerB"]) && 
71     isset($_REQUEST["PlayerC"]) && 
72     isset($_REQUEST["PlayerD"]) )
73   {
74     $PlayerA = $_REQUEST["PlayerA"];
75     $PlayerB = $_REQUEST["PlayerB"];
76     $PlayerC = $_REQUEST["PlayerC"];
77     $PlayerD = $_REQUEST["PlayerD"];
78     
79     $EmailA  = DB_get_email_by_name($PlayerA);
80     $EmailB  = DB_get_email_by_name($PlayerB);
81     $EmailC  = DB_get_email_by_name($PlayerC);
82     $EmailD  = DB_get_email_by_name($PlayerD);
83     
84     if($EmailA=="" || $EmailB=="" || $EmailC=="" || $EmailD=="")
85       {
86         echo "couldn't find one of the names, please start a new game";
87         exit();
88       }
89     
90     $useridA  = DB_get_userid_by_name($PlayerA);
91     $useridB  = DB_get_userid_by_name($PlayerB);
92     $useridC  = DB_get_userid_by_name($PlayerC);
93     $useridD  = DB_get_userid_by_name($PlayerD);
94     
95     /* create random numbers */
96     $randomNR       = create_array_of_random_numbers();
97     $randomNRstring = join(":",$randomNR);
98     
99     /* create game */
100     $followup = NULL;
101     if(isset($_REQUEST["followup"])) 
102       {
103         $followup= $_REQUEST["followup"];
104         mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', NULL, NULL,'pre','$followup' ,NULL)");
105       }
106     else
107       mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', NULL, NULL,'pre', NULL ,NULL)");
108     $game_id = mysql_insert_id();
109     
110     
111     $hashA = md5("AGameOfDoko".$game_id.$PlayerA.$EmailA);
112     $hashB = md5("AGameOfDoko".$game_id.$PlayerB.$EmailB);
113     $hashC = md5("AGameOfDoko".$game_id.$PlayerC.$EmailC);
114     $hashD = md5("AGameOfDoko".$game_id.$PlayerD.$EmailD);
115     
116     /* create hands */
117     mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridA).
118                 ", ".DB_quote_smart($hashA).", 'start','1',NULL,NULL,NULL,'false','false',NULL)");
119     $hand_idA = mysql_insert_id();                                                             
120     mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridB).
121                 ", ".DB_quote_smart($hashB).", 'start','2',NULL,NULL,NULL,'false','false',NULL)");
122     $hand_idB = mysql_insert_id();                                                             
123     mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridC).
124                 ", ".DB_quote_smart($hashC).", 'start','3',NULL,NULL,NULL,'false','false',NULL)");
125     $hand_idC = mysql_insert_id();                                                             
126     mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridD).
127                 ", ".DB_quote_smart($hashD).", 'start','4',NULL,NULL,NULL,'false','false',NULL)");
128     $hand_idD = mysql_insert_id();
129     
130     /* save cards */
131     for($i=0;$i<12;$i++)
132       mysql_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idA', '".$randomNR[$i]."', 'false')");
133     for($i=12;$i<24;$i++)
134       mysql_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idB', '".$randomNR[$i]."', 'false')");
135     for($i=24;$i<36;$i++)
136       mysql_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idC', '".$randomNR[$i]."', 'false')");
137     for($i=36;$i<48;$i++)
138       mysql_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idD', '".$randomNR[$i]."', 'false')");
139
140     /* send out email, check for error with email */
141     $message = "\n".
142       "you are invited to play a game of DoKo (that is to debug the program ;).\n".
143       "Place comments and bug reports here:\n".
144       "http://wiki.nubati.net/index.php?title=EmailDoko\n\n".
145       "The whole round would consist of the following players:\n".
146       "$PlayerA\n".
147       "$PlayerB\n".
148       "$PlayerC\n".
149       "$PlayerD\n\n".
150       "If you want to join this game, please follow this link:\n\n".
151       " ".$host."?me=";
152     
153     mymail($EmailA,"You are invited to a game of DoKo","Hello $PlayerA,\n".$message.$hashA);
154     mymail($EmailB,"You are invited to a game of DoKo","Hello $PlayerB,\n".$message.$hashB);
155     mymail($EmailC,"You are invited to a game of DoKo","Hello $PlayerC,\n".$message.$hashC);
156     mymail($EmailD,"You are invited to a game of DoKo","Hello $PlayerD,\n".$message.$hashD);
157         
158   }    
159 /* end set up a new game */
160
161 else if(isset($_REQUEST["me"]))
162   {
163      /* handle request from one specifig player,
164       * the hash is set on a per game base, so first just handle this game
165       * perhaps also show links to other games in a sidebar
166       */
167     
168     $me = $_REQUEST["me"];
169     
170     $myid = DB_get_userid_by_hash($me);
171     
172     if(!$myid)
173       {
174         echo "Can't find you in the database, please check the url.<br />\n";
175         echo "perhaps the game has been cancled.";
176          exit();
177       }
178     
179     DB_update_user_timestamp($myid);
180     $myname   = DB_get_name_by_hash($me);
181     $mystatus = DB_get_status_by_hash($me);
182
183     /* get game id */
184     $gameid = DB_get_gameid_by_hash($me);
185     
186     switch($mystatus)
187       {
188       case 'start':
189         check_want_to_play($me);
190         DB_set_hand_status_by_hash($me,'init');
191         break;
192         
193       case 'init':
194         if( !isset($_REQUEST["in"]) || !isset($_REQUEST["update"]))
195           {
196             DB_set_hand_status_by_hash($me,'start');
197             echo "you need to answer both question";
198           }
199         else
200           {
201             if($_REQUEST["in"] == "no")
202               {
203                 echo "TODO: email everyone that the game has been canceld<br />";
204                  /*something like
205                  for($i=0;$i<4;$i++)
206                    {
207                      $message = "Hello ".$player[$hash[$i]]["name"].",\n\n".
208                        "the game has been canceled due to the request of one of the players.\n";
209                      mymail($player[$hash[$i]]["email"],"[DoKo-Debug] the game has been canceled",$message); 
210                    }
211                  */
212                 DB_cancel_game($me);
213               }
214             else
215               {
216                 echo "thanks for joining the game... please scroll down";
217                 echo "TODO: make this page nicer<br />";
218                 echo "TODO: set card pref<br />";
219                 
220                 $mycards = DB_get_hand($me);
221                 sort($mycards);
222                 echo "<p class=\"mycards\">your cards are: <br />\n";
223                 foreach($mycards as $card) 
224                   display_card($card);
225                 echo "</p>\n";   
226                 
227                 check_for_sickness($me,$mycards);
228                 
229                 DB_set_hand_status_by_hash($me,'check');
230               }
231            }
232         break;
233         
234       case 'check':
235         echo "no checking at the moment... you need to play a normal game. At the moment you need to reload this page to finish the setup.";
236         if(!isset($_REQUEST["solo"])    || 
237            !isset($_REQUEST["wedding"]) ||
238            !isset($_REQUEST["poverty"]) ||
239            !isset($_REQUEST["nines"]) )
240           {
241             DB_set_hand_status_by_hash($me,'init');
242             /* problem: by setting it back to init, variables "in" and "update" are 
243              * not set, so the player will be send back to the start, after seeing his hand
244              */
245             echo "you need to fill out the form";
246           }
247         else
248           {
249             if( $_REQUEST["solo"]!="No")
250               {
251                 DB_set_solo_by_hash($me,$_REQUEST["solo"]);
252                 DB_set_sickness_by_hash($me,"solo");
253               }
254             else if($_REQUEST["wedding"] == "yes")
255               {
256                 echo "wedding was chosen<br />\n";
257                 DB_set_sickness_by_hash($me,"wedding");
258               }
259             else if($_REQUEST["poverty"] == "yes")
260               {
261                 echo "poverty was chosen<br />\n";
262                 DB_set_sickness_by_hash($me,"poverty");
263               }
264             else if($_REQUEST["nines"] == "yes")
265               {
266                 echo "nines was chosen<br />\n";
267                  DB_set_sickness_by_hash($me,"nines");
268               }
269           }
270         DB_set_hand_status_by_hash($me,'poverty');
271         
272         /* check all players and set game to final result, e.g. solo, wedding, povert, redeal */
273         
274         /* reset solo, etc from players who did say something, but it didn't matter? */
275         break;
276       case 'poverty':
277         echo "<br />poverty not handeled at the moment... you need to play a normal game<br />";
278         
279         /* only set this after all poverty, etc. are handeled*/
280         DB_set_hand_status_by_hash($me,'play');
281
282         /* check if the game can start  */
283         $userids = DB_get_all_userid_by_gameid($gameid);
284         $done=1;
285         foreach($userids as $user)
286           if(DB_get_hand_status_by_userid($user)!='play')
287             $done=0;
288
289         if($done)
290           DB_set_game_status_by_gameid($gameid,'play');
291
292         break;
293       case 'play':
294       case 'gameover': /* gameover and play, so that the tricks are visible for both */
295         display_news();
296         display_status();
297
298         $gamestatus =DB_get_game_status_by_gameid($gameid);
299         if($gamestatus == 'pre')
300           {
301             echo "you need to wait for the others... <br />";
302             break;
303           }
304         /* get trick ids */
305         $result = mysql_query("SELECT Hand_Card.card_id as card,".
306                               "       User.fullname as name,".
307                               "       Hand.position as position,".
308                               "       Play.sequence as sequence, ".
309                               "       Hand.hash     as hash,     ".
310                               "       Trick.id, ".
311                               "       Comment.comment ".
312                               "FROM Trick ".
313                               "LEFT JOIN Play ON Trick.id=Play.trick_id ".
314                               "LEFT JOIN Hand_Card ON Play.hand_card_id=Hand_Card.id ".
315                               "LEFT JOIN Hand ON Hand_Card.hand_id=Hand.id ".
316                               "LEFT JOIN User ON User.id=Hand.user_id ".
317                               "LEFT JOIN Comment ON Play.id=Comment.play_id ".
318                               "WHERE Trick.game_id='".$gameid."' ".
319                               "ORDER BY Trick.id,sequence ASC");
320         
321         
322         $trickNR = 1;
323         
324         $lasttrick = DB_get_max_trickid($gameid);
325         
326         $play = array(); /* needed to calculate winner later  */
327         $seq=1;          
328         $pos=0;
329         
330         echo "\n<ul class=\"oldtrick\">\n";
331         echo "  <li> Hello $myname!   History: </li>\n";
332         
333         while($r = mysql_fetch_array($result,MYSQL_NUM))
334           {
335             $seq   = $r[3];
336             $pos   = $r[2];
337             $trick = $r[5];
338             $comment = $r[6];
339             
340             if($trick!=$lasttrick && $seq==1)
341               {
342                 /* start of an old trick? */
343                 echo "  <li onclick=\"hl('$trickNR');\"><a href=\"#\">Trick $trickNR</a>\n".
344                   "    <div class=\"table\" id=\"trick".$trickNR."\">\n".
345                   "      <img class=\"table\" src=\"pics/table".($pos-1).".png\" alt=\"table\" />\n";
346               }
347             else if($trick==$lasttrick && $seq==1)
348               {
349                 /* start of a last trick? */
350                 echo "  <li onclick=\"hl('$trickNR');\"><a href=\"#\">Current Trick</a>\n".
351                   "    <div class=\"table\" id=\"trick".$trickNR."\">\n".
352                   "      <img class=\"table\" src=\"pics/table".($pos-1).".png\" alt=\"table\" />";
353               }
354             
355             /* display card */
356             echo "      <div class=\"card".($pos-1)."\">\n";
357             
358             $play[$pos]=$r[0];
359             
360             if($comment!="")
361               echo "        <span class=\"comment\">";
362             else
363               echo "        <span>";
364             
365             /* print name */
366             echo $r[1];
367             
368             /* check for comment */
369             if($comment!="")
370               echo "<span>".$comment."</span>";
371             echo "</span>\n        ";
372             
373             display_card($r[0]);
374             
375             echo "      </div>\n"; /* end div card */
376             
377             /* end of trick? */
378             if($seq==4)
379               {
380                 $trickNR++;
381                 echo "    </div>\n  </li>\n";  /* end div table, end li table */
382               }
383           }
384         if($seq!=4) 
385           echo "    </div>\n  </li>\n";  /* end div table, end li table */
386         
387         echo "</ul>\n";
388         
389         /* whos turn is it? */
390         if($seq==4)
391           {
392              $winner = get_winner($play); /* returns the position */
393              $next = $winner;
394           }
395         else
396           {
397             $next = $pos+1;
398           }
399         if($next==5) $next=1;
400         
401         /* my turn?, display cards as links, ask for comments*/
402         if(DB_get_pos_by_hash($me) == $next)
403           $myturn = 1;
404         else
405           $myturn = 0;
406
407         /* do we want to play a card? */
408         if(isset($_REQUEST["card"]) && $myturn)
409           {
410             $card   = $_REQUEST["card"];
411             $handid = DB_get_handid_by_hash($me); 
412             
413             /* check if we have card and that we haven't played it yet*/
414             /* set played in hand_card to true where hand_id and card_id*/
415             $result = mysql_query("SELECT id FROM Hand_Card WHERE played='false' and ".
416                                   "hand_id='$handid' AND card_id=".DB_quote_smart($card));
417             $r = mysql_fetch_array($result,MYSQL_NUM);
418             $handcardid = $r[0];
419             
420             if($handcardid)
421               {
422                 mysql_query("UPDATE Hand_Card SET played='true' WHERE hand_id='$handid' AND card_id=".DB_quote_smart($card));
423                 
424                 /* get trick id or start new trick */
425                 $a = DB_get_current_trickid($gameid);
426                 $trickid  = $a[0];
427                 $sequence = $a[1];
428                 
429                 $playid = DB_play_card($trickid,$handcardid,$sequence);
430
431                 /*check for coment */
432                 if(isset($_REQUEST["comment"]))
433                   {
434                     DB_insert_comment($_REQUEST["comment"],$playid,$myid);
435                   };  
436
437                 echo "<div class=\"card\">";
438                 echo " you played  <br />";
439                 display_card($card);
440                 echo "</div>\n";
441                 
442
443                 /*check if we still have cards left, else set status to gameover */
444                 if(sizeof(DB_get_hand($me))==0)
445                   {
446                     DB_set_hand_status_by_hash($me,'gameover');
447                     $mystatus='gameover';
448                   }
449                 
450                 /* if all players are done, set game status also to game over */
451                 $userids = DB_get_all_userid_by_gameid($gameid);
452                 $done=1;
453                 foreach($userids as $user)
454                   if(DB_get_hand_status_by_userid($user)!='gameover')
455                     $done=0;
456
457                 if($done)
458                   DB_set_game_status_by_gameid($gameid,"gameover");
459                 
460                 /* email next player */
461                 if(DB_get_game_status_by_gameid($gameid)=='play')
462                   {
463                     if($sequence==4)
464                       {
465                         $play   = DB_get_cards_by_trick($trickid);
466                         $winner = get_winner($play); /* returns the position */
467                         $next = $winner;
468                       }
469                     else
470                       {
471                         $next = DB_get_pos_by_hash($me)+1;
472                       }
473                     if($next==5) $next=1;
474
475                     echo "TODO: email next player at pos $next <br />";
476                     if($debug)
477                       echo "DEBUG:<a href=\"index.php?me=".DB_get_hash_from_game_and_pos($gameid,$next).
478                         "\"> next player </a> <br />\n";
479
480                   }
481               }
482             else
483               {
484                 echo "couldn't find card <br />\n";
485               }
486           }
487         else if(isset($_REQUEST["card"]) && !$myturn )
488           {
489             echo "please wait until it is your turn! <br />\n";
490           }
491         
492         $mycards = DB_get_hand($me);
493         sort($mycards);
494         echo "<div class=\"mycards\">\n";
495         
496         if($myturn && !isset($_REQUEST["card"]))
497           {
498             echo "Hello ".$myname.", it's your turn!  <br />\n";
499             echo "Your cards are: <br />\n";
500             echo "<form action=\"index.php?me=$me\" method=\"post\">\n";
501             foreach($mycards as $card) 
502               display_link_card($card);
503 ?>
504     <br />A short comments:<input name="comment" type="text" size="30" maxlength="50" /> 
505     <input type="hidden" name="me" value="<?php echo $me; ?>" />
506     <input type="submit" value="move" />
507  </form>
508  <?php
509          }
510         else if($mystatus=='play')
511           {
512             echo "Your cards are: <br />\n";
513             foreach($mycards as $card) 
514               display_card($card);
515           }
516         echo "</div>\n";
517
518         /* check if we need to set status to 'gameover' is done during playing of the card */
519         if($mystatus=='play')
520           break;
521    /* the following happens only when the gamestatus is 'gameover' */
522         /* check if game is over, display results */
523         if(DB_get_game_status_by_gameid($gameid)=='play')
524           {
525             echo "the game is over for you.. other people still need to play though";
526           }
527         else
528           {
529             echo "the game is over now... guess the final score should be displayed here...<br />\n";
530             
531             /* suggest a new game with the same people in it, just rotated once */
532             $names = DB_get_all_names_by_gameid($gameid);
533             
534             echo "Do you want to continue playing?(This will start a new game, with the next person as dealer.)\n";
535             echo "<form action=\"index.php\" methog=\"post\">\n";
536             echo "  <input type=\"hidden\" name=\"PlayerA\" value=\"".($names[1])."\" />\n";
537             echo "  <input type=\"hidden\" name=\"PlayerB\" value=\"".($names[2])."\" />\n";
538             echo "  <input type=\"hidden\" name=\"PlayerC\" value=\"".($names[3])."\" />\n";
539             echo "  <input type=\"hidden\" name=\"PlayerD\" value=\"".($names[0])."\" />\n";
540             echo "  <input type=\"hidden\" name=\"followup\" value=\"".($gameid)."\" />\n";
541             echo "  <input type=\"submit\" value=\"keep playing\" />\n";
542             echo "</form>\n";
543           }
544         break;
545       default:
546         echo "error in testing the status";
547       }
548     exit();
549   } 
550  else if(isset($_REQUEST["email"]) && isset($_REQUEST["password"]))
551   {
552     $ok=1;
553     $uid = DB_get_userid_by_email($_REQUEST["email"]);
554     if(!$uid)
555       $ok=0;
556     if(!DB_get_userid_by_passwd(md5($_REQUEST["password"])))
557       $ok=0;
558
559     if($ok)
560       {
561         $time = DB_get_user_timestamp($uid);
562         $unixtime =strtotime($time);
563         
564         $offset = DB_get_user_timezone($uid);
565         $zone = return_timezone($offset);
566         date_default_timezone_set($zone);
567
568         echo "ok. your logged in, now what? :) <br />last login: ";
569         echo date("r",$unixtime)."<br />";
570
571         DB_update_user_timestamp($uid);
572
573         echo "<p>these are the games you are playing in:<br />\n";
574         $result = mysql_query("SELECT hash,game_id from Hand WHERE user_id='$uid' AND status<>'gameover'" );
575         while( $r = mysql_fetch_array($result,MYSQL_NUM))
576           echo "<a href=\"http://doko.nubati.net/database/index.php?me=".$r[0]."\">game #".$r[1]." </a><br />";
577         echo "</p>\n";
578
579         $names = DB_get_all_names();
580         echo "<p>registered players:<br />\n";
581         foreach ($names as $name)
582           echo "$name <br />\n";
583         echo "</p>\n";
584         echo "<p>Want to start a new game? remember 4 names from the list above and visit ".
585           "<a href=\"http://doko.nubati.net/database/index.php?new\">this page.</a></p>";
586       }
587     else
588       {
589         echo "sorry email and password don't match <br />";
590       }
591     exit();
592   }
593 else if(isset($_REQUEST["register"]) )
594   {
595     echo "TODO: convert timezone into a menu<br />\n";
596     echo "TODO: figure out a way to handle passwrods <br />\n";
597 ?>
598         <form action="index.php" method="post">
599           <fieldset>
600             <legend>Register</legend>
601              <table>
602               <tr>
603                <td><label for="Rfullname">Full name:</label></td>
604                <td><input type="text" id="Rfullname" name="Rfullname" size="20" maxsize="30" /> </td>
605               </tr><tr>
606                <td><label for="Remail">Email:</label></td>
607                <td><input type="text" id="Remail" name="Remail" size="20" maxsize="30" /></td>
608               </tr><tr>
609                <td><label for="Rpassword">Password(will be displayed in cleartext on the next page):</label></td>
610                <td><input type="password" id="Rpassword" name="Rpassword" size="20" maxsize="30" /></td>
611               </tr><tr>
612                <td><label for="Rtimezone">Timezone:</label></td>
613                <td>
614                   <input type="text" id="Rtimezone" name="Rtimezone" size="4" maxsize="4" value="+1" />
615                </td>
616               </tr><tr>
617                <td colspan="2"> <input type="submit" value="register" /></td>
618              </table>
619           </fieldset>
620         </form>
621 <?php
622   }
623 else if(isset($_REQUEST["Rfullname"]) && 
624         isset($_REQUEST["Remail"]   ) && 
625         isset($_REQUEST["Rpassword"]) && 
626         isset($_REQUEST["Rtimezone"]) )
627   {
628         $ok=1;
629         if(DB_get_userid_by_name($_REQUEST["Rfullname"]))
630           {
631             echo "please chose another name<br />";
632             $ok=0;
633           }
634         if(DB_get_userid_by_email($_REQUEST["Remail"]))
635           {
636             echo "this email address is already used ?!<br />";
637             $ok=0;
638           }
639         if($ok)
640           {
641             $r=mysql_query("INSERT INTO User VALUES(NULL,".DB_quote_smart($_REQUEST["Rfullname"]).
642                       ",".DB_quote_smart($_REQUEST["Remail"]).
643                       ",".DB_quote_smart(md5($_REQUEST["Rpassword"])).
644                       ",".DB_quote_smart($_REQUEST["Rtimezone"]).",NULL)"); 
645             
646             if($r)
647               echo "  added you to the database";
648             else
649               echo " something went wrong";
650           }
651   }
652 else
653   { /* no new game, not in a game */
654 ?>
655     <p> If you want to play a game of Doppelkopf, you found the right place ;) </p>
656     <p> Please <a href="index.php?register">register</a>, in case you haven't done yet  <br />
657         or login with you email-address or name and password here:
658         <form action="index.php" method="post">
659           <fieldset>
660             <legend>Login</legend>
661              <table>
662               <tr>
663                <td><label for="email">Email:</label></td><td><input type="text" id="email" name="email" size="20" maxsize="30" /> </td>
664               </tr><tr>
665                <td><label for="password">Password:</label></td><td><input type="password" id="password" name="password" size="20" maxsize="30" /></td>
666               </tr><tr>
667                <td> <input type="submit" value="login" /></td>
668              </table>
669           </fieldset>
670         </form>
671  
672     </p>
673
674
675 <?php
676   }
677 ?>
678 </body>
679 </html>
680
681 <?php
682
683 DB_close();
684
685 /*
686  *Local Variables: 
687  *mode: php
688  *mode: hs-minor
689  *End:
690  */
691 ?>
692
693