$sql="select count(*) from Users where username=`" . $_REQUEST["UserName"] . "`";
if (ShowQueryResultScalar($sql) == 0)
  {
    $sql = "insert into Users(lastname,firstname,email,username,password,isdeleted,unit) " . "select `" . $_REQUEST["LastName"] . "`,`" . $_REQUEST["FirstName"] . 
"`,`" . $_REQUEST["Email"] . "`,`" . $_REQUEST["UserName"] . "`,`temp4pwd`,`1`,`" . $_REQUEST["unit"] . "`";

    $stat=ExecuteSQL($sql);
    $stat=MailSend($_SESSION[`PM_EMAIL`], $_SESSION[`PM_EMAIL`], "ProMan account request", $sql . ": " . $_SESSION["ProjectId"]);
    $stat=MailSend($_SESSION[`PM_EMAIL`], $_REQUEST["Email"], "ProMan account request", "Your Account Request for username `" . $_REQUEST["UserName"] . "` was submitted to the ProMan administrator.
Your password is `temp4pwd`
You will receive another email when the account is activated.
  Thank you.");
    echo "<h2>Your account request has been submitted.<p>An email has been sent to your address.<p>Thank you.</h2>";
    $stat=1;
  }
else
  {
    echo "<h2>ID: <b><u>" . $_REQUEST["UserName"] . "</u></b> has already been taken.<p>";
    $stat=0;
  }
