NEW FEATURE: removed RC1 from header
[e-DoKo.git] / include / register.php
1 <?php
2 /* make sure that we are not called from outside the scripts,
3  * use a variable defined in config.php to check this
4  */
5 if(!isset($HOST))
6   exit;
7
8 /* new user wants to register */
9 if(myisset("Rfullname","Remail","Rpassword","Rtimezone") )
10   {
11     global $HOST,$INDEX;
12
13     /* is this name already in use/ */
14     $ok=1;
15     if(DB_get_userid('name',$_REQUEST["Rfullname"]))
16       {
17         echo "please chose another name<br />";
18         $ok=0;
19       }
20     /* check if email address is already used */
21     if(DB_get_userid('email',$_REQUEST["Remail"]))
22       {
23         echo "this email address is already used ?!<br />";
24         $ok=0;
25       }
26
27     /* everything ok, go ahead and create user */
28     if($ok)
29       {
30         $r=DB_query("INSERT INTO User VALUES(NULL,".DB_quote_smart($_REQUEST["Rfullname"]).
31                     ",".DB_quote_smart($_REQUEST["Remail"]).
32                     ",".DB_quote_smart(md5($_REQUEST["Rpassword"])).
33                     ",".DB_quote_smart($_REQUEST["Rtimezone"]).",NULL,NULL)");
34
35         if($r)
36           {
37             /* Set session, so that new user doesn't need to log in */
38             $myname = DB_get_name('email',$_REQUEST['Remail']);
39             $_SESSION["name"] = $myname;
40
41             echo " Welcome to e-DoKo, you are now registered, please visit the".
42               " <a href=\"".$HOST.$INDEX."\">homepage</a> to continue.";
43           }
44         else
45           echo " something went wrong, couldn't add you to the database, please contact $ADMIN_NAME at $ADMIN_EMAIL.";
46       }
47   }
48  else
49    {
50      /* No information for new user given, ouput a page for registration */
51      echo "<p><br /><strong> IMPORTANT: passwords are going over the net as clear text, so pick an easy password. ".
52        "No need to pick anything complicated here ;)<br />";
53      echo "N.B. Your email address will be exposed to other players whom you play games with. ";
54      echo "<br /><br /></strong></p>";
55      ?>
56         <form action="index.php?action=register" method="post">
57           <fieldset>
58             <legend>Register</legend>
59              <table>
60               <tr>
61                <td><label for="Rfullname">Full name:</label></td>
62                <td><input type="text" id="Rfullname" name="Rfullname" size="20" maxsize="30" /> </td>
63               </tr><tr>
64                <td><label for="Remail">Email:</label></td>
65                <td><input type="text" id="Remail" name="Remail" size="20" maxsize="30" /></td>
66               </tr><tr>
67                <td><label for="Rpassword">Password(will be displayed in cleartext on the next page):</label></td>
68                <td><input type="password" id="Rpassword" name="Rpassword" size="20" maxsize="30" /></td>
69               </tr><tr>
70                <td><label for="Rtimezone">Timezone:</label></td>
71                <td>
72 <?php
73                output_select_timezone("Rtimezone");
74 ?>
75                </td>
76               </tr><tr>
77                <td colspan="2"> <input type="submit" value="register" /></td>
78              </table>
79           </fieldset>
80         </form>
81 <?php
82    }
83 ?>