LAYOUT: last login and logout text where displayed incorrectly sometimes
[e-DoKo.git] / register.php
1 <?php
2 error_reporting(E_ALL);
3
4 include_once("config.php");      
5 include_once("output.php");      /* html output only */
6 include_once("db.php");          /* database only */
7 include_once("functions.php");   /* the rest */
8
9 config_check();
10
11 if(DB_open()<0)
12   {
13     output_header();
14     echo "Database error, can't connect... Please wait a while and try again. ".
15       "If the problem doesn't go away feel free to contact $ADMIN_NAME at $ADMIN_EMAIL.";
16     output_footer(); 
17     exit(); 
18   }
19
20
21 /* done major error checking, output header of HTML page */
22 output_header();
23
24 /* new user wants to register */
25 if(myisset("Rfullname","Remail","Rpassword","Rtimezone") )
26   {
27     $ok=1;
28     if(DB_get_userid_by_name($_REQUEST["Rfullname"]))
29       {
30         echo "please chose another name<br />";
31         $ok=0;
32       }
33     if(DB_get_userid_by_email($_REQUEST["Remail"]))
34       {
35         echo "this email address is already used ?!<br />";
36         $ok=0;
37       }
38     if($ok)
39       {
40         $r=mysql_query("INSERT INTO User VALUES(NULL,".DB_quote_smart($_REQUEST["Rfullname"]).
41                        ",".DB_quote_smart($_REQUEST["Remail"]).
42                        ",".DB_quote_smart(md5($_REQUEST["Rpassword"])).
43                        ",".DB_quote_smart($_REQUEST["Rtimezone"]).",NULL)"); 
44         
45         if($r)
46           echo " Welcome to e-DoKo, you are now registered, please visit the".
47             " <a href=\"$host\">homepage</a> to continue.";
48         else
49           echo " something went wrong, couldn't add you to the database, please contact $ADMIN_NAME at $ADMIN_EMAIL.";
50       }
51    }
52 /* page for registration */
53  else
54    {
55      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 />";
56      ?>
57         <form action="register.php" method="post">
58           <fieldset>
59             <legend>Register</legend>
60              <table>
61               <tr>
62                <td><label for="Rfullname">Full name:</label></td>
63                <td><input type="text" id="Rfullname" name="Rfullname" size="20" maxsize="30" /> </td>
64               </tr><tr>
65                <td><label for="Remail">Email:</label></td>
66                <td><input type="text" id="Remail" name="Remail" size="20" maxsize="30" /></td>
67               </tr><tr>
68                <td><label for="Rpassword">Password(will be displayed in cleartext on the next page):</label></td>
69                <td><input type="password" id="Rpassword" name="Rpassword" size="20" maxsize="30" /></td>
70               </tr><tr>
71                <td><label for="Rtimezone">Timezone:</label></td>
72                <td>
73                   <select id="Rtimezone" name="Rtimezone" size="1">
74                      <option value="Europe/London">Berlin</option>
75                      <option value="Europe/Berlin">Berlin</option>
76                      <option value="America/Vancouver">Berkeley</option>
77                      <option value="Pacific/Auckland">Wellington</option>
78                   </select>
79                  (If your timezone is not listed, just select whatever you want and email the admin your correct time zone.)
80                </td>
81               </tr><tr>
82                <td colspan="2"> <input type="submit" value="register" /></td>
83              </table>
84           </fieldset>
85         </form>
86 <?php
87    }
88
89 output_footer();
90
91 DB_close();
92
93 /*
94  *Local Variables: 
95  *mode: php
96  *mode: hs-minor
97  *End:
98  */
99 ?>