BUGFIX: typo in scoring algorithm
[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     $ok=1;
13     if(DB_get_userid('name',$_REQUEST["Rfullname"]))
14       {
15         echo "please chose another name<br />";
16         $ok=0;
17       }
18     if(DB_get_userid('email',$_REQUEST["Remail"]))
19       {
20         echo "this email address is already used ?!<br />";
21         $ok=0;
22       }
23     if($ok)
24       {
25         $r=mysql_query("INSERT INTO User VALUES(NULL,".DB_quote_smart($_REQUEST["Rfullname"]).
26                        ",".DB_quote_smart($_REQUEST["Remail"]).
27                        ",".DB_quote_smart(md5($_REQUEST["Rpassword"])).
28                        ",".DB_quote_smart($_REQUEST["Rtimezone"]).",NULL,NULL)"); 
29         
30         if($r)
31           {
32             /* Set session, so that new user doesn't need to log in */
33             $myname = DB_get_name('email',$_REQUEST['Remail']);
34             $_SESSION["name"] = $myname;
35             
36             echo "myname $myname --";
37             
38             echo " Welcome to e-DoKo, you are now registered, please visit the".
39               " <a href=\"".$HOST.$INDEX."\">homepage</a> to continue.";
40           }
41         else
42           echo " something went wrong, couldn't add you to the database, please contact $ADMIN_NAME at $ADMIN_EMAIL.";
43       }
44    }
45 /* page for registration */
46  else
47    {
48      echo "IMPORTANT: passwords are going over the net as clear text, so pick an easy password. No need to pick anything complicated here ;)<br /><br />";
49      ?>
50         <form action="index.php?action=register" method="post">
51           <fieldset>
52             <legend>Register</legend>
53              <table>
54               <tr>
55                <td><label for="Rfullname">Full name:</label></td>
56                <td><input type="text" id="Rfullname" name="Rfullname" size="20" maxsize="30" /> </td>
57               </tr><tr>
58                <td><label for="Remail">Email:</label></td>
59                <td><input type="text" id="Remail" name="Remail" size="20" maxsize="30" /></td>
60               </tr><tr>
61                <td><label for="Rpassword">Password(will be displayed in cleartext on the next page):</label></td>
62                <td><input type="password" id="Rpassword" name="Rpassword" size="20" maxsize="30" /></td>
63               </tr><tr>
64                <td><label for="Rtimezone">Timezone:</label></td>
65                <td>
66                   <select id="Rtimezone" name="Rtimezone" size="1">
67                      <option value="Europe/London">Berlin</option>
68                      <option value="Europe/Berlin">Berlin</option>
69                      <option value="America/Vancouver">Berkeley</option>
70                      <option value="Pacific/Auckland">Wellington</option>
71                   </select>
72                  (If your timezone is not listed, just select whatever you want and email the admin your correct time zone.)
73                </td>
74               </tr><tr>
75                <td colspan="2"> <input type="submit" value="register" /></td>
76              </table>
77           </fieldset>
78         </form>
79 <?php
80    }
81
82
83 ?>