BUGIFX: output was displayed twice
[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     global $HOST,$INDEX;
28     $ok=1;
29     if(DB_get_userid_by_name($_REQUEST["Rfullname"]))
30       {
31         echo "please chose another name<br />";
32         $ok=0;
33       }
34     if(DB_get_userid_by_email($_REQUEST["Remail"]))
35       {
36         echo "this email address is already used ?!<br />";
37         $ok=0;
38       }
39     if($ok)
40       {
41         $r=mysql_query("INSERT INTO User VALUES(NULL,".DB_quote_smart($_REQUEST["Rfullname"]).
42                        ",".DB_quote_smart($_REQUEST["Remail"]).
43                        ",".DB_quote_smart(md5($_REQUEST["Rpassword"])).
44                        ",".DB_quote_smart($_REQUEST["Rtimezone"]).",NULL)"); 
45         
46         if($r)
47           echo " Welcome to e-DoKo, you are now registered, please visit the".
48             " <a href=\"".$HOST.$INDEX."\">homepage</a> to continue.";
49         else
50           echo " something went wrong, couldn't add you to the database, please contact $ADMIN_NAME at $ADMIN_EMAIL.";
51       }
52    }
53 /* page for registration */
54  else
55    {
56      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 />";
57      ?>
58         <form action="register.php" method="post">
59           <fieldset>
60             <legend>Register</legend>
61              <table>
62               <tr>
63                <td><label for="Rfullname">Full name:</label></td>
64                <td><input type="text" id="Rfullname" name="Rfullname" size="20" maxsize="30" /> </td>
65               </tr><tr>
66                <td><label for="Remail">Email:</label></td>
67                <td><input type="text" id="Remail" name="Remail" size="20" maxsize="30" /></td>
68               </tr><tr>
69                <td><label for="Rpassword">Password(will be displayed in cleartext on the next page):</label></td>
70                <td><input type="password" id="Rpassword" name="Rpassword" size="20" maxsize="30" /></td>
71               </tr><tr>
72                <td><label for="Rtimezone">Timezone:</label></td>
73                <td>
74                   <select id="Rtimezone" name="Rtimezone" size="1">
75                      <option value="Europe/London">Berlin</option>
76                      <option value="Europe/Berlin">Berlin</option>
77                      <option value="America/Vancouver">Berkeley</option>
78                      <option value="Pacific/Auckland">Wellington</option>
79                   </select>
80                  (If your timezone is not listed, just select whatever you want and email the admin your correct time zone.)
81                </td>
82               </tr><tr>
83                <td colspan="2"> <input type="submit" value="register" /></td>
84              </table>
85           </fieldset>
86         </form>
87 <?php
88    }
89
90 output_footer();
91
92 DB_close();
93
94 /*
95  *Local Variables: 
96  *mode: php
97  *mode: hs-minor
98  *End:
99  */
100 ?>