<?php include 'rdzen/init.php'; protect_page(); admin_protect(); include 'zawartosc/ogolne/header.php'; ?> <h2>Zarządzanie użytkownikami</h2> <?php $mysql_server = 'localhost'; $mysql_imie = 'root'; $mysql_password = ''; $mysql_database = 'serwis'; $mysql_table = 'ik_users'; if (!$db) { } mysql_select_db($mysql_database, $db) or die('Błąd: Nie mogę wybrać tablicy bazy danych!<br>'.mysql_error()); if ($action == 'delete') { $sql = "DELETE FROM ".$mysql_table." WHERE ".$mysql_table.".user_id = '$user_id'"; exit; } else $sql = "UPDATE `".$mysql_table."` SET `login` = '$login', "; $sql = $sql . "`password` = '$crypt_pass',"; } $sql = $sql . " `last_name` = '$last_name', `first_name` = '$first_name', `email` = '$email', `status` = $status, `type` = $type WHERE `user_id` = $user_id"; if ($action == 'update') { exit; } else if ($action == 'create') { $sql = "SELECT first_name FROM ".$mysql_table." WHERE first_name = '".$_POST['first_name']."'"; exit; } $sql = "INSERT `".$mysql_table."` (`login`, `first_name`, `last_name`, `password`, `email`, `datarejestracji`, `status`, `ip`, `type`) VALUES ('$login', '$first_name', '$last_name', '$crypt_pass', '$email', NOW(), '$status', '".$_SERVER['REMOTE_ADDR']."', '$type')"; exit; } } ?> <style type="text/css"> th { font-family: Tahoma; font-weight: normal; text-decoration: none; background-color: #878787; color: #FFFFFF; text-align: left; } td { font-family: Tahoma; font-weight: normal; text-decoration: none; color: #000000; } </style> <?php if (($action == 'edit') || ($action == 'new')) { $login_value = ''; $imie_value = ''; $nazwisko_value = ''; $email_value = ''; $status_value = ''; $type_value = ''; $sql = "SELECT * FROM ".$mysql_table." WHERE user_id = '".$user_id."' AND type = type"; $user_id_value = $data['user_id']; $login_value = $data['login']; $imie_value = $data['first_name']; $nazwisko_value = $data['last_name']; $email_value = $data['email']; $ip_value = $data['ip']; $status_value = $data['status']; $type_value = $data['type']; } ?> <center> <table border="0" style="text-align: right;"> <?php if ($action == 'new') { } else { } ?> <tr> <td>Login:</td> <tr> <td>Imie:</td> </tr> <tr> <td>Nazwisko:</td> </tr> <tr> <td>E-mail:</td> </tr> <tr> <td>Hasło:</td> <td><input type="password" size="50" name="password" value=""></td> </tr> <tr> <td>Status:</td> <td style="text-align:left"> <select name="status" size="1"> </select> </td> </tr> <tr> <td>Typ:</td> <td style="text-align:left"> <!-- <select name="type" size="1"> //Moja wesoła twórczość stworzyła coś takiego - ale to nie działa. <option <?php //echo ($type_value == "0" ? "selected" : ""); ?> value="0">Zwykły użytkownik</option> <option <?php //echo ($type_value == "1" ? "selected" : ""); ?> value="1">Pracownik</option> <option <?php //echo ($type_value == "2" ? "selected" : ""); ?> value="2">Administrator</option> </select> --> </td> </tr> <tr> <td> </td> <td style="text-align:left"><input type="submit" name="cmdSubmit" value="Zapisz"> <span> </span> <input type="reset" name="cmdReset" value="Resetuj"> <input type="button" name="cmdBack" value="Wróć" onclick="<?php echo "location.href='" . basename(__FILE__) . "'";?>"></td> </tr> </table> </form> </center> <?php } } else { ?> <table id="tabelka" class="display"> <thead> <tr> <th><center>Login</center></th> <th><center>Imie</center></th> <th><center>Nazwisko</center></th> <th><center>E-mail</center></th> <th><center>IP</center></th> <th><center>Typ</center></th> <th><center>Status</center></th> <th><center>Data Rejestracji</center></th> <th><center>Akcja</center></th> </tr> </thead> <tbody> <tr> <?php $sql = "SELECT * FROM ".$mysql_table." ORDER BY user_id ASC"; ?> <td> <center> <input type="image" src="images/user_edit_24x24.png" title="Edytuj użytkownika" style="padding: 1px 10px 1px 0;"></a> <input type="image" src="images/user_delete_24x24.png" title="Usuń użytkownika" style="padding: 1px 0 1px 10px;"></a> </center> </td> </tr> <?php } ?> </tbody> <tfoot> <tr> <th><center>Login</center></th> <th><center>Imie</center></th> <th><center>Nazwisko</center></th> <th><center>E-mail</center></th> <th><center>IP</center></th> <th><center>Typ</center></th> <th><center>Status</center></th> <th><center>Data Rejestracji</center></th> <th><center>Akcja</center></th> </tr> </tfoot> </table><br /> <?php } include 'zawartosc/ogolne/footer.php'; ?>
Chcę zrobić wybieranie rodzaju/typu konta użytkownika podczas edycji jego konta. Obecne rozwiązanie nie nadaje się do niczego. Jak to zrobić by było poprawne?