Witam mam Problem z dodawaniem użytkownika, nie wiem dla czego nie dodaje mi go do bazy
Tak wygląda mój skrypt
Dane przekazywane do zapisu
if (http://www.php.net/isset($_POST['newuser'])) { $username = $_POST['username']; $password = http://www.php.net/md5($_POST['password']); $email = $_POST['email']; $fname = $_POST['fname']; $lname = $_POST['lname']; $access = $_POST['access']; adduser($username, $password, $fname, $lname, $email, $access); }
function adduser($username, $password, $fname, $lname, $email, $access) { $db = dbconnect(); $insert1 = http://www.php.net/array( "username" => $username, "password" => $password, "fname" => $fname, "lname" => $lname, "email" => $email, "access" => $level ); $db->insert("members", $insert1); if (http://www.php.net/empty($_SESSION["username"])) { $userusername = "WHMCS"; } else { $userusername = $_SESSION["username"]; } addevent($userusername, " added " . $username . " as a registered user"); http://www.php.net/echo "<div class=\"alert alert-success alert-dismissable\"><i class=\"fa fa-check\"></i><button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">×</button><b>Success!</b> Added " . $username . " successfully!</div>"; }
http://www.php.net/var_dump($insert1);
<http://december.com/html/4/element/form.html method="post" action=""> <http://december.com/html/4/element/div.html class="box-body"> <http://december.com/html/4/element/div.html class="form-group"> <http://december.com/html/4/element/label.html for="">Username</http://december.com/html/4/element/label.html> <http://december.com/html/4/element/input.html type="text" class="form-control" id="" name="username" placeholder="Username"> </http://december.com/html/4/element/div.html> <http://december.com/html/4/element/div.html class="form-group"> <http://december.com/html/4/element/label.html for="">Password</http://december.com/html/4/element/label.html> <http://december.com/html/4/element/input.html type="password" class="form-control" name="password" id="" placeholder="Password"> </http://december.com/html/4/element/div.html> <http://december.com/html/4/element/div.html class="form-group"> <http://december.com/html/4/element/label.html for="">First Name</http://december.com/html/4/element/label.html> <http://december.com/html/4/element/input.html type="text" class="form-control" name="fname" id="" placeholder="First Name"> </http://december.com/html/4/element/div.html> <http://december.com/html/4/element/div.html class="form-group"> <http://december.com/html/4/element/label.html for="">Last Name</http://december.com/html/4/element/label.html> <http://december.com/html/4/element/input.html type="text" class="form-control" name="lname" id="" placeholder="Last Name"> </http://december.com/html/4/element/div.html> <http://december.com/html/4/element/div.html class="form-group"> <http://december.com/html/4/element/label.html for="">Email</http://december.com/html/4/element/label.html> <http://december.com/html/4/element/input.html type="email" class="form-control" name="email" id="" placeholder="Email"> </http://december.com/html/4/element/div.html> <http://december.com/html/4/element/div.html class="form-group"> <http://december.com/html/4/element/label.html>Access Level</http://december.com/html/4/element/label.html> <http://december.com/html/4/element/select.html class="form-control" name="access"> <http://december.com/html/4/element/option.html value="5">Administrator</http://december.com/html/4/element/option.html> <http://december.com/html/4/element/option.html value="4">Technician</http://december.com/html/4/element/option.html> <http://december.com/html/4/element/option.html value="3">Helper</http://december.com/html/4/element/option.html> <http://december.com/html/4/element/option.html value="2">Read Only</http://december.com/html/4/element/option.html> <http://december.com/html/4/element/option.html value="1">User</http://december.com/html/4/element/option.html> <http://december.com/html/4/element/option.html value="0">Disabled</http://december.com/html/4/element/option.html> </http://december.com/html/4/element/select.html> </http://december.com/html/4/element/div.html> </http://december.com/html/4/element/div.html><!-- /.box-body --> <http://december.com/html/4/element/div.html class="box-footer"> <http://december.com/html/4/element/input.html type="hidden" name="newuser" value="yes"> <http://december.com/html/4/element/button.html type="submit" name="go" class="btn btn-primary">Add user</http://december.com/html/4/element/button.html> </http://december.com/html/4/element/div.html> </http://december.com/html/4/element/form.html>
W funkcji "access" => $level nie masz takiej zmiennej.
Zmieniłem parametry ale nadal nie zapisuje
tak wygląda funkcja która powinna zapisywać
function adduser($username, $password, $fname, $lname, $email, $level) { $db = dbconnect(); $insert = http://www.php.net/array( "username" => $username, "password" => $password, "fname" => $fname, "lname" => $lname, "email" => $email, "access" => $level ); $db->insert("members", $insert); if (http://www.php.net/empty($_SESSION["username"])) { $userusername = "WHMCS"; } else { $userusername = $_SESSION["username"]; } addevent($userusername, " added " . $username . " as a registered user"); http://www.php.net/echo "<div class=\"alert alert-success alert-dismissable\"><i class=\"fa fa-check\"></i><button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">×</button><b>Success!</b> Added " . $username . " successfully!</div>"; }
if (http://www.php.net/isset($_POST['newuser'])) { $username = $_POST['username']; $password = http://www.php.net/md5($_POST['password']); $email = $_POST['email']; $fname = $_POST['fname']; $lname = $_POST['lname']; $access = $_POST['access']; adduser($username, $password, $fname, $lname, $email, $access); }
<http://december.com/html/4/element/form.html method="post" action=""> <http://december.com/html/4/element/div.html class="box-body"> <http://december.com/html/4/element/div.html class="form-group"> <http://december.com/html/4/element/label.html for="">Username</http://december.com/html/4/element/label.html> <http://december.com/html/4/element/input.html type="text" class="form-control" id="" name="username" placeholder="Username"> </http://december.com/html/4/element/div.html> <http://december.com/html/4/element/div.html class="form-group"> <http://december.com/html/4/element/label.html for="">Password</http://december.com/html/4/element/label.html> <http://december.com/html/4/element/input.html type="password" class="form-control" name="password" id="" placeholder="Password"> </http://december.com/html/4/element/div.html> <http://december.com/html/4/element/div.html class="form-group"> <http://december.com/html/4/element/label.html for="">First Name</http://december.com/html/4/element/label.html> <http://december.com/html/4/element/input.html type="text" class="form-control" name="fname" id="" placeholder="First Name"> </http://december.com/html/4/element/div.html> <http://december.com/html/4/element/div.html class="form-group"> <http://december.com/html/4/element/label.html for="">Last Name</http://december.com/html/4/element/label.html> <http://december.com/html/4/element/input.html type="text" class="form-control" name="lname" id="" placeholder="Last Name"> </http://december.com/html/4/element/div.html> <http://december.com/html/4/element/div.html class="form-group"> <http://december.com/html/4/element/label.html for="">Email</http://december.com/html/4/element/label.html> <http://december.com/html/4/element/input.html type="email" class="form-control" name="email" id="" placeholder="Email"> </http://december.com/html/4/element/div.html> <http://december.com/html/4/element/div.html class="form-group"> <http://december.com/html/4/element/label.html>Access Level</http://december.com/html/4/element/label.html> <http://december.com/html/4/element/select.html class="form-control" name="access"> <http://december.com/html/4/element/option.html value="5">Administrator</http://december.com/html/4/element/option.html> <http://december.com/html/4/element/option.html value="4">Technician</http://december.com/html/4/element/option.html> <http://december.com/html/4/element/option.html value="3">Helper</http://december.com/html/4/element/option.html> <http://december.com/html/4/element/option.html value="2">Read Only</http://december.com/html/4/element/option.html> <http://december.com/html/4/element/option.html value="1">User</http://december.com/html/4/element/option.html> <http://december.com/html/4/element/option.html value="0">Disabled</http://december.com/html/4/element/option.html> </http://december.com/html/4/element/select.html> </http://december.com/html/4/element/div.html> </http://december.com/html/4/element/div.html><!-- /.box-body --> <http://december.com/html/4/element/div.html class="box-footer"> <http://december.com/html/4/element/input.html type="hidden" name="newuser" value="yes"> <http://december.com/html/4/element/button.html type="submit" name="go" class="btn btn-primary">Add user</http://december.com/html/4/element/button.html> </http://december.com/html/4/element/div.html> </http://december.com/html/4/element/form.html>
Nie wiem co robi ani czym jest twoja funkcja zapisująca dane. Na jej poziomie wyświetl jakiś wyjątek/błąd zapytania albo sprawdź w logach.
Właśnie o to chodzi że nie ma błędów zapisu niby operacja dodania się udaje a użytkownika w bazie nie ma dodanego bo korzystam
https://github.com/gaza1994/SHOUTcast-Manager Do zarządzania serwerami SHOUTcast.
Ale coś nie działa tak jak miał działać
Po insert zrób var_dump($db->getLastError());
ok w bazie nie było wartości domyślnej dla jednej wartości którą mam w bazie
Dzięki Viking za pomoc.
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)