	

    <?php // signup
     
    include("../bin/function.php");
    session_start();
    if (!isset($_POST['submitok'])):
        // Display the user signup form
        ?>
     
    <form style="width:200px" method="post" action="<?php $_SERVER['PHP_SELF']?>">
    <label for="username"><?php echo _("Username:"); ?></label>
    <input name="username"></input>
    <label for="firstname"><?php echo _("First name:"); ?></label>
    <input name="firstname"></input>
    <label for="lastname"><?php echo _("Last name:"); ?></label>
    <input name="lastname"></input>
    <label for="email"><?php echo _("Email:"); ?></label>
    <input name="email"></input>
    <label for="newsletter"><?php echo _("Subscribe to newsletter:"); ?></label>
    <input type="checkbox" name="newsletter" checked="yes"/>
    <img src="../bin/captcha.php"></img>
    <input name="captcha"></input>
    <input type="submit" name="submitok" value="<?php echo _("register");?>" />
    <?php echo $_SESSION["security_code"];?>
    </form>
     
        <?php
    else:
    session_start();
    ?>
    <script type="text/javascript">
    alert('<?php echo $_SESSION["security_code"];?>');
    </script>
    <?php
        // Process signup submission
        /*
        dbConnect();
     
        if ($_POST['username']=='' or $_POST['firstname']==''
          or $_POST['lastname']=='' or $_POST['email'] == '') {
            error('One or more required fields were left blank.<br /><br />'.
                  'Please fill them in and try again.');
        }
       
        // Check for existing user with the new id
        $sql = "SELECT COUNT(*) FROM user WHERE username = '$_POST[username]'";
        $result = mysql_query($sql);
        if (!$result) {    
            error('A database error occurred in processing your '.
                  'submission.<br />If this error persists, please '.
                  'contact you@example.com.');
        }
        if (mysql_result($result,0,0)>0) {
            error('A user already exists with your chosen userid.<br />'.
                  'Please try another.');
        }  
        $newsletter = ($_POST[newsletter] == "on" ? 1 : 0);
        $newpass = generatePassword();
        $newpassMd = md5($newpass);
        $sql = "INSERT INTO user SET
                  username = '$_POST[username]',
                  password = PASSWORD('$newpassMd'),
                  firstname = '$_POST[firstname]',
                  lastname = '$_POST[lastname]',
                  email = '$_POST[email]',
                      newsletter = '$newsletter'";
        if (!mysql_query($sql))
            error('A database error occurred in processing your '.
                  'submission.<br/>If this error persists, please '.
                  'contact you@example.com.<br/>' . mysql_error());
                 
        // Email the new password to the person.
        $message = "G'Day!
     
    Your personal account for the Project Web Site
    has been created! To log in, proceed to the
    following address:
     
        http://www.example.com/
     
    Your personal login ID and password are as
    follows:
     
        username: $_POST[username]
        password: $newpass
     
    You aren't stuck with this password! Your can
    change it at any time after you have logged in.
     
    If you have any problems, feel free to contact me at
    <you@example.com>.
     
    -Your Name
     Your Site Webmaster
    ";
    echo $message;
             
        ?>
        <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
          <title> Registration Complete </title>
          <meta http-equiv="Content-Type"
            content="text/html; charset=iso-8859-1" />
        </head>
        <body>
        <p><strong>User registration successful!</strong></p>
        <p>Your userid and password have been emailed to
           <strong><?php $_POST['email']?></strong>, the email address
           you just provided in your registration form. To log in,
           click <a href="index.php">here</a> to return to the login
           page, and enter your new personal userid and password.</p>
        </body>
        </html>
        <?php
        */
    endif;
    ?>

