users.php
changeset 79 0c0aa144356a
parent 76 0748816801b2
child 82 c255196bc447
equal deleted inserted replaced
78:effde559e0e9 79:0c0aa144356a
    19  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    19  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    20  */
    20  */
    21 
    21 
    22 require_once("inc/toolkit.inc.php");
    22 require_once("inc/toolkit.inc.php");
    23 
    23 
    24 if($_POST["submit"]
    24 if(isset($_POST["submit"])
    25 && $_POST["username"] != ""
    25 && isset($_POST['username']) && $_POST["username"] != ""
    26 && $_POST["password"] != "" 
    26 && isset($_POST['password']) && $_POST["password"] != "" 
    27 && $_POST["fullname"] != ""
    27 && isset($_POST['fullname']) && $_POST["fullname"] != ""
    28 && $_POST["email"] != ""
    28 && isset($_POST['email']) && $_POST["email"] != ""
    29 && $_POST["level"] > 0)
    29 && isset($_POST['level']) && $_POST["level"] > 0)
    30 {
    30 {
    31 	if(substr_count($_POST["username"], " ") == 0)
    31 	if(substr_count($_POST["username"], " ") == 0)
    32 	{
    32 	{
    33 		if(strlen($_POST["password"]) < 8)
    33 		if(strlen($_POST["password"]) < 8)
    34 		{
    34 		{
    43         else
    43         else
    44         {
    44         {
    45         	$error = _('Usernames can\'t contain spaces');
    45         	$error = _('Usernames can\'t contain spaces');
    46         }
    46         }
    47 }
    47 }
    48 elseif($_POST["submit"])
    48 elseif(isset($_POST["submit"]))
    49 {
    49 {
    50 	$error = _('Please fill in all fields');
    50 	$error = _('Please fill in all fields');
    51 }
    51 }
    52 
    52 
    53 include_once("inc/header.inc.php");
    53 include_once("inc/header.inc.php");
    54 if ($error != "") 
    54 if (isset($error) && $error != "") 
    55 {
    55 {
    56 ?>
    56 ?>
    57 	<div class="error"><?php echo $error ; ?></div>
    57 	<div class="error"><?php echo $error ; ?></div>
    58 <?php
    58 <?php
    59 }
    59 }
   118       <h3><?php echo _('Create new user'); ?></h3>
   118       <h3><?php echo _('Create new user'); ?></h3>
   119       <form method="post" action="users.php">
   119       <form method="post" action="users.php">
   120        <table>
   120        <table>
   121         <tr>
   121         <tr>
   122          <td class="n"><?php echo _('User name'); ?>:</td>
   122          <td class="n"><?php echo _('User name'); ?>:</td>
   123          <td class="n"><input type="text" class="input" name="username" value="<?php if ($error) print $_POST["username"]; ?>"></td>
   123          <td class="n"><input type="text" class="input" name="username" value="<?php if (isset($error)) print $_POST["username"]; ?>"></td>
   124 	</tr>
   124 	</tr>
   125 	<tr>
   125 	<tr>
   126 	 <td class="n"><?php echo _('Full name'); ?>:</td>
   126 	 <td class="n"><?php echo _('Full name'); ?>:</td>
   127 	 <td class="n"><input type="text" class="input" NAME="fullname" VALUE="<?php if ($error) print $_POST["fullname"]; ?>"></td>
   127 	 <td class="n"><input type="text" class="input" NAME="fullname" VALUE="<?php if (isset($error)) print $_POST["fullname"]; ?>"></td>
   128 	</tr>
   128 	</tr>
   129 	<tr>
   129 	<tr>
   130 	 <td class="n"><?php echo _('Password'); ?>:</td>
   130 	 <td class="n"><?php echo _('Password'); ?>:</td>
   131 	 <td class="n"><input type="password" class="input" NAME="password" VALUE="<?php if ($error) print $_POST["password"]; ?>"></td>
   131 	 <td class="n"><input type="password" class="input" NAME="password" VALUE="<?php if (isset($error)) print $_POST["password"]; ?>"></td>
   132 	</tr>
   132 	</tr>
   133 	<tr>
   133 	<tr>
   134 	 <td class="n"><?php echo _('E-mail'); ?>:</td>
   134 	 <td class="n"><?php echo _('E-mail'); ?>:</td>
   135 	 <td class="n"><input type="text" class="input" NAME="email" VALUE="<?php if ($error) print $_POST["email"]; ?>"></td>
   135 	 <td class="n"><input type="text" class="input" NAME="email" VALUE="<?php if (isset($error)) print $_POST["email"]; ?>"></td>
   136 	</tr>
   136 	</tr>
   137 	<tr>
   137 	<tr>
   138 	 <td class="n"><?php echo _('User level'); ?>:</td>
   138 	 <td class="n"><?php echo _('User level'); ?>:</td>
   139 	 <td class="n">
   139 	 <td class="n">
   140 	  <select name="level">
   140 	  <select name="level">
   144 	  </select>
   144 	  </select>
   145 	 </td>
   145 	 </td>
   146 	</tr>
   146 	</tr>
   147         <tr>
   147         <tr>
   148 	 <td class="n"><?php echo _('Description'); ?>:</td>
   148 	 <td class="n"><?php echo _('Description'); ?>:</td>
   149 	 <td class="n"><textarea rows="6" cols="30" class="inputarea" name="description"><?php if ($error) print $_POST["description"]; ?></textarea></td>
   149 	 <td class="n"><textarea rows="6" cols="30" class="inputarea" name="description"><?php if (isset($error)) print $_POST["description"]; ?></textarea></td>
   150 	</tr>
   150 	</tr>
   151 	<tr>
   151 	<tr>
   152 	 <td class="n"><?php echo _('Active'); ?>:</td>
   152 	 <td class="n"><?php echo _('Active'); ?>:</td>
   153 	 <td class="n"><input type="checkbox" name="active" value="1" checked></td>
   153 	 <td class="n"><input type="checkbox" name="active" value="1" checked></td>
   154 	</tr>
   154 	</tr>