<html>
<! AddUser.php                                                >
<! Chapter 11, Oracle Database XE PHP Web Programming         >
<! by Michael McLaughlin                                      >
<!                                                            >
<! This demonstrates basic HTTP authentication add user       >
<! program, which uses two library files - one for the basic  >
<! operation functions and the other for the form master.     >
<head>
<title>
  Chapter 11 : AddUser.php
</title>
<style type="text/css">
  div#centered {border:0;height:50%;top:25%;left:25%;width:50%;
                position:absolute;}
</style>
</head>
<body>
<?php
  // Include form library.
  @include_once("BasicAuthentication.inc");
  @include_once("BasicForms.inc");
  
  // Check valid credentials.
  $valid_user = verify_authentication();

  //Prompt for credentials when they're missing.
  if (!$valid_user)
  {
    authenticate();
  }
  else
  {
    // Assign inputs to variables.
    $userid = $_POST['userid'];
    $passwd = $_POST['passwd'];

    // Set error default and write new credentials.
    if (($code = verify_valid_credentials($userid,$passwd)) == 0)
    {
      // Join user and encrypted password into a colon delimited string.
      $data = implode(":",array($userid,md5($passwd)));

      // Calll the function to append a line to a file.
      write_string("simplepassword.txt",$data);
    }

    // Display next user form.
    addUserForm(array("code"=>$code
	                 ,"form"=>"AddUser.php"
	                 ,"userid"=>$userid));
  }
?>
</body>
</html>