4a38ed8c9bde2ba498a86c0266c7aab1d9afe85c
[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";
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                               "FROM Trick ".
312                               "LEFT JOIN Play ON Trick.id=Play.trick_id ".
313                               "LEFT JOIN Hand_Card ON Play.hand_card_id=Hand_Card.id ".
314                               "LEFT JOIN Hand ON Hand_Card.hand_id=Hand.id ".
315                               "LEFT JOIN User ON User.id=Hand.user_id ".
316                               "WHERE Trick.game_id='".$gameid."' ".
317                               "ORDER BY Trick.id,sequence ASC");
318         
319         
320         $trickNR = 1;
321         
322         $lasttrick = DB_get_max_trickid($gameid);
323         
324         $play = array(); /* needed to calculate winner later  */
325         $seq=1;          
326         $pos=0;
327         
328         echo "\n<ul class=\"oldtrick\">\n";
329         echo "  <li> Hello $myname!   History: </li>\n";
330         
331         while($r = mysql_fetch_array($result,MYSQL_NUM))
332           {
333             $seq   = $r[3];
334             $pos   = $r[2];
335             $trick = $r[5];
336             
337             if($trick!=$lasttrick && $seq==1)
338               {
339                 /* start of an old trick? */
340                 echo "  <li onclick=\"hl('$trickNR');\"><a href=\"#\">Trick $trickNR</a>\n".
341                   "    <div class=\"table\" id=\"trick".$trickNR."\">\n".
342                   "      <img class=\"table\" src=\"pics/table".($pos-1).".png\" alt=\"table\" />\n";
343               }
344             else if($trick==$lasttrick && $seq==1)
345               {
346                 /* start of a last trick? */
347                 echo "  <li onclick=\"hl('$trickNR');\"><a href=\"#\">Current Trick</a>\n".
348                   "    <div class=\"table\" id=\"trick".$trickNR."\">\n".
349                   "      <img class=\"table\" src=\"pics/table".($pos-1).".png\" alt=\"table\" />";
350               }
351             
352             /* display card */
353             echo "      <div class=\"card".($pos-1)."\">\n";
354             
355             $play[$pos]=$r[0];
356             
357             $comment=0;
358             if($comment)
359               echo "        <span class=\"comment\">";
360             else
361               echo "        <span>";
362             
363             /* print name */
364             echo $r[1];
365             
366             /* check for comment */
367             if($comment)
368               echo "<span>".$comment."</span>";
369             echo "</span>\n        ";
370             
371             display_card($r[0]);
372             
373             echo "      </div>\n"; /* end div card */
374             
375             /* end of trick? */
376             if($seq==4)
377               {
378                 $trickNR++;
379                 echo "    </div>\n  </li>\n";  /* end div table, end li table */
380               }
381           }
382         if($seq!=4) 
383           echo "    </div>\n  </li>\n";  /* end div table, end li table */
384         
385         echo "</ul>\n";
386         
387         /* whos turn is it? */
388         if($seq==4)
389           {
390              $winner = get_winner($play); /* returns the position */
391              $next = $winner;
392           }
393         else
394           {
395             $next = $pos+1;
396           }
397         if($next==5) $next=1;
398         
399         /* my turn?, display cards as links, ask for comments*/
400         if(DB_get_pos_by_hash($me) == $next)
401           $myturn = 1;
402         else
403           $myturn = 0;
404
405         if(isset($_REQUEST["comment"]))
406           {
407         
408           }  
409         /* do we want to play a card? */
410         if(isset($_REQUEST["card"]) && $myturn)
411           {
412             $card   = $_REQUEST["card"];
413             $handid = DB_get_handid_by_hash($me); 
414             
415             /* check if we have card and that we haven't played it yet*/
416             /* set played in hand_card to true where hand_id and card_id*/
417             $result = mysql_query("SELECT id FROM Hand_Card WHERE played='false' and ".
418                                   "hand_id='$handid' AND card_id=".DB_quote_smart($card));
419             $r = mysql_fetch_array($result,MYSQL_NUM);
420             $handcardid = $r[0];
421             
422             if($handcardid)
423               {
424                 mysql_query("UPDATE Hand_Card SET played='true' WHERE hand_id='$handid' AND card_id=".DB_quote_smart($card));
425                 
426                 /* get trick id or start new trick */
427                 $a = DB_get_current_trickid($gameid);
428                 $trickid  = $a[0];
429                 $sequence = $a[1];
430                 
431                 DB_play_card($trickid,$handcardid,$sequence);
432                 echo "<div class=\"card\">";
433                 echo " you played  <br />";
434                 display_card($card);
435                 echo "</div>\n";
436                 
437
438                 /*check if we still have cards left, else set status to gameover */
439                 if(sizeof(DB_get_hand($me))==0)
440                   {
441                     DB_set_hand_status_by_hash($me,'gameover');
442                     $mystatus='gameover';
443                   }
444                 
445                 /* if all players are done, set game status also to game over */
446                 $userids = DB_get_all_userid_by_gameid($gameid);
447                 $done=1;
448                 foreach($userids as $user)
449                   if(DB_get_hand_status_by_userid($user)!='gameover')
450                     $done=0;
451
452                 if($done)
453                   DB_set_game_status_by_gameid($gameid,"gameover");
454                 
455                 /* email next player */
456                 if(DB_get_game_status_by_gameid($gameid)=='play')
457                   {
458                     if($sequence==4)
459                       {
460                         $play   = DB_get_cards_by_trick($trickid);
461                         $winner = get_winner($play); /* returns the position */
462                         $next = $winner;
463                       }
464                     else
465                       {
466                         $next = DB_get_pos_by_hash($me)+1;
467                       }
468                     if($next==5) $next=1;
469
470                     echo "TODO: email next player at pos $next <br />";
471                     if($debug)
472                       echo "DEBUG:<a href=\"index.php?me=".DB_get_hash_from_game_and_pos($gameid,$next).
473                         "\"> next player </a> <br />\n";
474
475                   }
476               }
477             else
478               {
479                 echo "couldn't find card <br />\n";
480               }
481           }
482         else if(isset($_REQUEST["card"]) && !$myturn )
483           {
484             echo "please wait until it is your turn! <br />\n";
485           }
486         
487         $mycards = DB_get_hand($me);
488         sort($mycards);
489         echo "<div class=\"mycards\">\n";
490         
491         if($myturn && !isset($_REQUEST["card"]))
492           {
493             echo "Hello ".$myname.", it's your turn!  <br />\n";
494             echo "Your cards are: <br />\n";
495             echo "<form action=\"index.php?me=$me\" method=\"post\">\n";
496             foreach($mycards as $card) 
497               display_link_card($card);
498 ?>
499     <br />A short comments:<input name="comment" type="text" size="30" maxlength="50" /> 
500     <input type="hidden" name="me" value="<?php echo $me; ?>" />
501     <input type="submit" value="move" />
502  </form>
503  <?php
504          }
505         else if($mystatus=='play')
506           {
507             echo "Your cards are: <br />\n";
508             foreach($mycards as $card) 
509               display_card($card);
510           }
511         echo "</div>\n";
512
513         /* check if we need to set status to 'gameover' is done during playing of the card */
514         if($mystatus=='play')
515           break;
516    /* the following happens only when the gamestatus is 'gameover' */
517         /* check if game is over, display results */
518         if(DB_get_game_status_by_gameid($gameid)=='play')
519           {
520             echo "the game is over for you.. other people still need to play though";
521           }
522         else
523           {
524             echo "the game is over now... guess the final score should be displayed here...<br />\n";
525             
526             /* suggest a new game with the same people in it, just rotated once */
527             $names = DB_get_all_names_by_gameid($gameid);
528             
529             echo "Do you want to continue playing?(This will start a new game, with the next person as dealer.)\n";
530             echo "<form action=\"index.php\" methog=\"post\">\n";
531             echo "  <input type=\"hidden\" name=\"PlayerA\" value=\"".($names[1])."\" />\n";
532             echo "  <input type=\"hidden\" name=\"PlayerB\" value=\"".($names[2])."\" />\n";
533             echo "  <input type=\"hidden\" name=\"PlayerC\" value=\"".($names[3])."\" />\n";
534             echo "  <input type=\"hidden\" name=\"PlayerD\" value=\"".($names[0])."\" />\n";
535             echo "  <input type=\"hidden\" name=\"followup\" value=\"".($gameid)."\" />\n";
536             echo "  <input type=\"submit\" value=\"keep playing\" />\n";
537             echo "</form>\n";
538           }
539         break;
540       default:
541         echo "error in testing the status";
542       }
543     exit();
544   } 
545  else if(isset($_REQUEST["email"]) && isset($_REQUEST["password"]))
546   {
547     $ok=1;
548     $uid = DB_get_userid_by_email($_REQUEST["email"]);
549     if(!$uid)
550       $ok=0;
551     if(!DB_get_userid_by_passwd(md5($_REQUEST["password"])))
552       $ok=0;
553
554     if($ok)
555       {
556         $time = DB_get_user_timestamp($uid);
557         $unixtime =strtotime($time);
558         
559         $offset = DB_get_user_timezone($uid);
560         $zone = return_timezone($offset);
561         date_default_timezone_set($zone);
562
563         echo "ok. your logged in, now what? :) <br />last login: ";
564         echo date("r",$unixtime)."<br />";
565
566         DB_update_user_timestamp($uid);
567
568         echo "<p>these are the games you are playing in:<br />\n";
569         $result = mysql_query("SELECT hash,game_id from Hand WHERE user_id='$uid' AND status<>'gameover'" );
570         while( $r = mysql_fetch_array($result,MYSQL_NUM))
571           echo "<a href=\"http://doko.nubati.net/database/index.php?me=".$r[0]."\">game #".$r[1]." </a><br />";
572         echo "</p>\n";
573
574         $names = DB_get_all_names();
575         echo "<p>registered players:<br />\n";
576         foreach ($names as $name)
577           echo "$name <br />\n";
578         echo "</p>\n";
579         echo "<p>Want to start a new game? remember 4 names from the list above and visit ".
580           "<a href=\"http://doko.nubati.net/database/index.php?new\">this page.</a></p>";
581       }
582     else
583       {
584         echo "sorry email and password don't match <br />";
585       }
586     exit();
587   }
588 else if(isset($_REQUEST["register"]) )
589   {
590     echo "TODO: convert timezone into a menu<br />\n";
591     echo "TODO: figure out a way to handle passwrods <br />\n";
592 ?>
593         <form action="index.php" method="post">
594           <fieldset>
595             <legend>Register</legend>
596              <table>
597               <tr>
598                <td><label for="Rfullname">Full name:</label></td>
599                <td><input type="text" id="Rfullname" name="Rfullname" size="20" maxsize="30" /> </td>
600               </tr><tr>
601                <td><label for="Remail">Email:</label></td>
602                <td><input type="text" id="Remail" name="Remail" size="20" maxsize="30" /></td>
603               </tr><tr>
604                <td><label for="Rpassword">Password(will be displayed in cleartext on the next page):</label></td>
605                <td><input type="password" id="Rpassword" name="Rpassword" size="20" maxsize="30" /></td>
606               </tr><tr>
607                <td><label for="Rtimezone">Timezone:</label></td>
608                <td>
609                   <input type="text" id="Rtimezone" name="Rtimezone" size="4" maxsize="4" value="+1" />
610                </td>
611               </tr><tr>
612                <td colspan="2"> <input type="submit" value="register" /></td>
613              </table>
614           </fieldset>
615         </form>
616 <?php
617   }
618 else if(isset($_REQUEST["Rfullname"]) && 
619         isset($_REQUEST["Remail"]   ) && 
620         isset($_REQUEST["Rpassword"]) && 
621         isset($_REQUEST["Rtimezone"]) )
622   {
623         $ok=1;
624         if(DB_get_userid_by_name($_REQUEST["Rfullname"]))
625           {
626             echo "please chose another name<br />";
627             $ok=0;
628           }
629         if(DB_get_userid_by_email($_REQUEST["Remail"]))
630           {
631             echo "this email address is already used ?!<br />";
632             $ok=0;
633           }
634         if($ok)
635           {
636             $r=mysql_query("INSERT INTO User VALUES(NULL,".DB_quote_smart($_REQUEST["Rfullname"]).
637                       ",".DB_quote_smart($_REQUEST["Remail"]).
638                       ",".DB_quote_smart(md5($_REQUEST["Rpassword"])).
639                       ",".DB_quote_smart($_REQUEST["Rtimezone"]).",NULL)"); 
640             
641             if($r)
642               echo "  added you to the database";
643             else
644               echo " something went wrong";
645           }
646   }
647 else
648   { /* no new game, not in a game */
649 ?>
650     <p> If you want to play a game of Doppelkopf, you found the right place ;) </p>
651     <p> Please <a href="index.php?register">register</a>, in case you haven't done yet  <br />
652         or login with you email-address or name and password here:
653         <form action="index.php" method="post">
654           <fieldset>
655             <legend>Login</legend>
656              <table>
657               <tr>
658                <td><label for="email">Email:</label></td><td><input type="text" id="email" name="email" size="20" maxsize="30" /> </td>
659               </tr><tr>
660                <td><label for="password">Password:</label></td><td><input type="password" id="password" name="password" size="20" maxsize="30" /></td>
661               </tr><tr>
662                <td> <input type="submit" value="login" /></td>
663              </table>
664           </fieldset>
665         </form>
666  
667     </p>
668
669
670 <?php
671   }
672 ?>
673 </body>
674 </html>
675
676 <?php
677
678 DB_close();
679
680 /*
681  *Local Variables: 
682  *mode: php
683  *mode: hs-minor
684  *End:
685  */
686 ?>
687
688