Insert customer type into database

Asked

Viewed 71 times

0

Hello guys I’m new here on the forum and would like a help to put for when the customer select a sex insert inside the database. Thanks in advance.

<?php
require_once('includes/Autoloader.php');
$db = new Conn();

$user_ip = $_SERVER['REMOTE_ADDR'];
$usuario = isset($_POST['usuario']) ? $db->mssql_escape_string(trim($_POST['usuario'])) : false;
$nome = isset($_POST['nome']) ? $db->mssql_escape_string(trim($_POST['nome'])) : false;
$password = isset($_POST['password']) ? $db->mssql_escape_string(trim($_POST['password'])) : false;
$password2 = isset($_POST['password2']) ? $db->mssql_escape_string(trim($_POST['password2'])) : false;
$email = isset($_POST['email']) ? $db->mssql_escape_string(trim($_POST['email'])) : false;
$errors = array();
$success = false;
if(isset($_POST['submit'])){
	$db->_open_conn();
	
	if(empty($usuario)){
		$errors[] = 'Por favor coloque um nome de usuário.';
	}else if(strlen($usuario) < 4 || strlen($usuario) > 16){
		$errors[] = 'O nome de usuário deve conter entre 4-16 caracteres.';
	}else if(ctype_alnum($usuario) === false){
		$errors[] = 'O nome de usuário só pode ser letras e números.';
	}else{
		$stmt = $db->conn->prepare("SELECT UsuarioID FROM C_Client.dbo.Clientes WHERE UsuarioID=?");
		$stmt->bindValue(1, $usuario, PDO::PARAM_STR);
		$stmt->execute();
		if(!$stmt){
			$errors[] = 'Falha ao verificar o nome do usuário.';
		}
		elseif($data=$stmt->fetch(PDO::FETCH_NUM)){
			$errors[] = 'Este nome de usuário já está em uso. Por favor escolha outro.';
		}
	}
	if(empty($password)){
		$errors[] = 'Por favor insira uma senha';
	}else if(strlen($password) < 6 || strlen($password) > 20){
		$errors[] = 'A senha deve conter entre 6-20 caracteres.';
	}else if($password != $password2){
		$errors[] = 'As senhas não combinam';
	}

    if(empty($email)){
        $errors[] = 'Por favor insira um endereço de E-mail';
    }else if(strlen($email) < 12 || strlen($email) > 64){
        $errors[] = 'O endereço de E-Mail deve conter entre 12-64 caracteres.';
    }else{
        $stmt = $db->conn->prepare("SELECT Email FROM C_Client.dbo.Clientes WHERE Email=?");
        $stmt->bindValue(1, $email, PDO::PARAM_STR);
        $stmt->execute();
        if(!$stmt){
            $errors[] = 'Falha ao verificar o Endereço de E-Mail.';
        }
        elseif($data=$stmt->fetch(PDO::FETCH_NUM)){
            $errors[] = 'Este endereço de e-mail já está em uso. Por favor utilize outro.';
        }
    }

    if(empty($nome)){
        $errors[] = 'Por favor insira um nome válido.';
    }else if(strlen($nome) < 4 || strlen($nome) > 64){
        $errors[] = 'O nome deve conter entre 4-64 caracteres.';
    }

	if(count($errors) == 0){
		$userip = $_SERVER['REMOTE_ADDR'];
		$stmt	=	$db->conn->prepare("INSERT INTO C_Client.dbo.Clientes (UsuarioID, Nome, Password, Email)VALUES (?,?,?,?)");

		$stmt->bindValue(1, $usuario, PDO::PARAM_STR);
        $stmt->bindValue(2, $nome, PDO::PARAM_STR);
        $stmt->bindValue(3, $password, PDO::PARAM_STR);
        $stmt->bindValue(4, $user_ip, PDO::PARAM_STR);
        $stmt->bindValue(5, $email, PDO::PARAM_STR);

		if($stmt->execute()){
			$success = "{$nome} sua conta foi criada com sucesso!";
		}else{
			$errors[] = 'Falha ao criar uma conta, por favor tente mais tarde!';
		}
	}
}
?>
  <!DOCTYPE html>
  <html lang="pt-br">

  <head>
    <title>Country</title>
    <meta charset="utf-8" ">
    <meta name="viewport " content="width=device-width, inital-scale1.0 ">
    <link rel="icon " href="img/favicon.png ">
    <!-- MATERIALIZER CSS -->
    <link rel="stylesheet " href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css ">
    <!-- CUSTOM CSS -->
    <link rel="stylesheet " href="css/custom.css ">
    <!-- DOWN-CONTENT CSS -->
    <link rel="stylesheet " href="css/down-content.css ">
    <!-- TOOLTIPSTER CSS -->
    <link rel="stylesheet " href="css/tooltipster.bundle.css ">
    <link rel="stylesheet " href="css/tooltipster-follower.css ">
    <!-- GOOGLE ICONS -->
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons " rel="stylesheet ">
    <!-- GOOGLE FONTS -->
    <link href="//fonts.googleapis.com/css?family=Cinzel+Decorative:400,700 " rel="stylesheet ">
    <!-- - -->
    <link rel="stylesheet " href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css ">


</head>
<body>

    <div id="top " class="navbar ">
        <?php include "top.php " ?>
    </div>

<div id="main " class="row container banner col s12 center ">
    <div class="logo ">
        <img src="img/favicon.png ">
    </div>

    <div class="panel ">
    <div class="top "></div>
    <div class="body ">
        <div class="title ">Cadastro
            <br>
            <div class="separador ">
                    <img src="img/panel/separador-horizontal.png ">
            </div>
        </div>
        <p>Bem Vindo</p>

        <form method="post ">

        <?php if(count($errors)){ ?>
                        <ul id="error ">
                        <?php foreach($errors as $error){ ?>
                            <li><?php echo $error; ?></li>
                        <?php } ?>
                        </ul>
                    <?php }else{
                        ?><div class="success "><?php echo $success; ?></div><?
                    } ?>


        <div class="input-field ">
            <i class="material-icons prefix icon-color-ca ">person</i>
            <input value="<?php if(isset($_POST[ 'nome'])){ echo $_POST[ 'nome']; } ?>" type="texto" name="nome" id="nome" maxlength="64" placeholder="NOME" required="required"/>
    </div>

    <div class="input-field">
      <i class="material-icons prefix icon-color-ca">person</i>
      <input value="<?php if(isset($_POST['usuario'])){ echo $_POST['usuario']; } ?>" type="texto" name="usuario" id="usuario" maxlength="16" placeholder="USÚARIO" required="required" />
    </div>

    <div class="input-field">
      <i class="material-icons prefix icon-color-ca">lock</i>
      <input value="<?php if(isset($_POST['password'])){ echo $_POST['password']; } ?>" type="password" name="password" id="password" maxlength="16" placeholder="SENHA" onfocus="removeDisabled()" required="required" pattern="(?=^.{8,16}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$"
      />

    </div>

    <div class="input-field">
      <i class="material-icons prefix icon-color-ca">repeat</i>
      <input value="<?php if(isset($_POST['password2'])){ echo $_POST['password2']; } ?>" type="password" name="password2" id="password2" maxlength="16" placeholder="REPITA A SENHA" required="required" pattern="(?=^.{8,16}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$"
      />

    </div>

    <div class="input-field">
      <i class="material-icons prefix icon-color-ca">email</i>
      <input value="<?php if(isset($_POST['email'])){ echo $_POST['email']; } ?>" type="texto" name="email" id="email" maxlength="64" placeholder="E-MAIL" required="required" />

    </div>

    <center>
      <select class="browser-default personalizar-select">
        <option value="">Sexo</option>
        <option value="1">Masculino</option>
        <option value="2">Feminino</option>
        <option value="3">Outro</option>
      </select>
    </center>



    <input type="reset" name="reset" value="Limpar" />
    <input type="submit" name="submit" value="Criar Conta" />
    </form>
    </div>
    <div class="bottom"></div>
    </div>
    </div>
    <div class="divider-footer"></div>

    <footer id="rodape">
      <div class="Pane Pane--dirtLight Pane--bgBottom bordered">
        <div class="Pane-bg">
          <div class="Pane-overlay"></div>
        </div>
        <div class="Pane-content">
          <div class="gutter-normal gutter-vertical">
            <div class="SocialLinks SocialLinks--wow">
              <div class="SocialLinks-title FooterText">2019 &copy; Country Todos os Direitos Reservados</div>
            </div>
          </div>
        </div>
      </div>
    </footer>
    </div>


    <!-- JQUERY JS -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <!-- MATERIALIZE JS -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
    <!-- - -->
    <script type="text/javascript" src="https://rawgit.com/iamceege/tooltipster/4.2.5/dist/js/tooltipster.bundle.min.js"></script>
    <!-- - -->
    <script type="text/javascript" src="https://rawgit.com/louisameline/tooltipster-follower/0.1.5/dist/js/tooltipster-follower.min.js"></script>
    <!-- - -->
    <script type="text/javascript" src="js/tooltip.js"></script>


    <!-- sidenav -->
    <script type="text/javascript">
      document.addEventListener('DOMContentLoaded', function() {
        var elems = document.querySelectorAll('.sidenav');
        var instances = M.Sidenav.init(elems, options);
      });

      $(document).ready(function() {
        $('.sidenav').sidenav();
      });
    </script>

    <!-- DOMContent -->
    <script type="text/javascript">
      document.addEventListener('DOMContentLoaded', function() {
        var elems = document.querySelectorAll('.dropdown-trigger');
        var instances = M.Dropdown.init(elems, options);
      });

      $('.dropdown-trigger').dropdown();
    </script>

    <!-- DropDown -->
    <script>
      $('.dropdown-button').dropdown({
        container: document.body
      });

      $(document).ready(function() {
        $('.sidenav').sidenav();
        $('.collapsible').collapsible();
        $('.tooltipped').tooltip();
        $('.modal').modal();
      }); // end of document ready
    </script>

    <script type="text/javascript">
      $(document).ready(function(e) {
        $('form[name=reg_form]').process_reg_form();
      });
    </script>

    <!-- select -->
    <script type="text/javascript">
      document.addEventListener('DOMContentLoaded', function() {
        var elems = document.querySelectorAll('select');
        var instances = M.FormSelect.init(elems, options);
      });

      $(document).ready(function() {
        $('select').formSelect();
      });
    </script>

    <script type="text/javascript">
      /*  jQuery Nice Select - v1.0
          https://github.com/hernansartorio/jquery-nice-select
          Made by Hernán Sartorio  */
      ! function(e) {
        e.fn.niceSelect = function(t) {
          function s(t) {
            t.after(e("<div></div>").addClass("nice-select").addClass(t.attr("class") || "").addClass(t.attr("disabled") ? "disabled" : "").attr("tabindex", t.attr("disabled") ? null : "0").html('<span class="current"></span><ul class="list"></ul>'));
            var s = t.next(),
              n = t.find("option"),
              i = t.find("option:selected");
            s.find(".current").html(i.data("display") || i.text()), n.each(function(t) {
              var n = e(this),
                i = n.data("display");
              s.find("ul").append(e("<li></li>").attr("data-value", n.val()).attr("data-display", i || null).addClass("option" + (n.is(":selected") ? " selected" : "") + (n.is(":disabled") ? " disabled" : "")).html(n.text()))
            })
          }
          if ("string" == typeof t) return "update" == t ? this.each(function() {
            var t = e(this),
              n = e(this).next(".nice-select"),
              i = n.hasClass("open");
            n.length && (n.remove(), s(t), i && t.next().trigger("click"))
          }) : "destroy" == t ? (this.each(function() {
            var t = e(this),
              s = e(this).next(".nice-select");
            s.length && (s.remove(), t.css("display", ""))
          }), 0 == e(".nice-select").length && e(document).off(".nice_select")) : console.log('Method "' + t + '" does not exist.'), this;
          this.hide(), this.each(function() {
            var t = e(this);
            t.next().hasClass("nice-select") || s(t)
          }), e(document).off(".nice_select"), e(document).on("click.nice_select", ".nice-select", function(t) {
            var s = e(this);
            e(".nice-select").not(s).removeClass("open"), s.toggleClass("open"), s.hasClass("open") ? (s.find(".option"), s.find(".focus").removeClass("focus"), s.find(".selected").addClass("focus")) : s.focus()
          }), e(document).on("click.nice_select", function(t) {
            0 === e(t.target).closest(".nice-select").length && e(".nice-select").removeClass("open").find(".option")
          }), e(document).on("click.nice_select", ".nice-select .option:not(.disabled)", function(t) {
            var s = e(this),
              n = s.closest(".nice-select");
            n.find(".selected").removeClass("selected"), s.addClass("selected");
            var i = s.data("display") || s.text();
            n.find(".current").text(i), n.prev("select").val(s.data("value")).trigger("change")
          }), e(document).on("keydown.nice_select", ".nice-select", function(t) {
            var s = e(this),
              n = e(s.find(".focus") || s.find(".list .option.selected"));
            if (32 == t.keyCode || 13 == t.keyCode) return s.hasClass("open") ? n.trigger("click") : s.trigger("click"), !1;
            if (40 == t.keyCode) {
              if (s.hasClass("open")) {
                var i = n.nextAll(".option:not(.disabled)").first();
                i.length > 0 && (s.find(".focus").removeClass("focus"), i.addClass("focus"))
              } else s.trigger("click");
              return !1
            }
            if (38 == t.keyCode) {
              if (s.hasClass("open")) {
                var l = n.prevAll(".option:not(.disabled)").first();
                l.length > 0 && (s.find(".focus").removeClass("focus"), l.addClass("focus"))
              } else s.trigger("click");
              return !1
            }
            if (27 == t.keyCode) s.hasClass("open") && s.trigger("click");
            else if (9 == t.keyCode && s.hasClass("open")) return !1
          });
          var n = document.createElement("a").style;
          return n.cssText = "pointer-events:auto", "auto" !== n.pointerEvents && e("html").addClass("no-csspointerevents"), this
        }
      }(jQuery);

      $(document).ready(function() {
        $('.personalizar-select').niceSelect();
      });
    </script>

    </body>

  </html>

1 answer

1


When Voce sends a form using PHP, the form fields are sent via the attribute name, then the first step is to include this attribute in your HTML code, in the element select. I also changed the attributes value of their options. It is difficult to identify sexes 1, 2 and 3; makes more sense something like "M", "F" and "O".

The second step, eh "read" this field in your PHP code. On line 12, I include a new variable that will receive the field sex. On lines 65 to 80, I changed the SQL to include the field Sex and insert the variable we created before.

The last step for all of this to work, is to change your database and include the field Sex on the table of Customers. If you do not, the information is not saved.

Here is the code set:

<?php
require_once('includes/Autoloader.php');
$db = new Conn();

$user_ip = $_SERVER['REMOTE_ADDR'];
$usuario = isset($_POST['usuario']) ? $db->mssql_escape_string(trim($_POST['usuario'])) : false;
$nome = isset($_POST['nome']) ? $db->mssql_escape_string(trim($_POST['nome'])) : false;
$password = isset($_POST['password']) ? $db->mssql_escape_string(trim($_POST['password'])) : false;
$password2 = isset($_POST['password2']) ? $db->mssql_escape_string(trim($_POST['password2'])) : false;
$email = isset($_POST['email']) ? $db->mssql_escape_string(trim($_POST['email'])) : false;
$sexo = isset($_POST['sexo']) ? $db->mssql_escape_string(trim($_POST['sexo'])) : false;
$errors = array();
$success = false;
if(isset($_POST['submit'])){
    $db->_open_conn();

    if(empty($usuario)){
        $errors[] = 'Por favor coloque um nome de usuário.';
    }else if(strlen($usuario) < 4 || strlen($usuario) > 16){
        $errors[] = 'O nome de usuário deve conter entre 4-16 caracteres.';
    }else if(ctype_alnum($usuario) === false){
        $errors[] = 'O nome de usuário só pode ser letras e números.';
    }else{
        $stmt = $db->conn->prepare("SELECT UsuarioID FROM C_Client.dbo.Clientes WHERE UsuarioID=?");
        $stmt->bindValue(1, $usuario, PDO::PARAM_STR);
        $stmt->execute();
        if(!$stmt){
            $errors[] = 'Falha ao verificar o nome do usuário.';
        }
        elseif($data=$stmt->fetch(PDO::FETCH_NUM)){
            $errors[] = 'Este nome de usuário já está em uso. Por favor escolha outro.';
        }
    }
    if(empty($password)){
        $errors[] = 'Por favor insira uma senha';
    }else if(strlen($password) < 6 || strlen($password) > 20){
        $errors[] = 'A senha deve conter entre 6-20 caracteres.';
    }else if($password != $password2){
        $errors[] = 'As senhas não combinam';
    }

    if(empty($email)){
        $errors[] = 'Por favor insira um endereço de E-mail';
    }else if(strlen($email) < 12 || strlen($email) > 64){
        $errors[] = 'O endereço de E-Mail deve conter entre 12-64 caracteres.';
    }else{
        $stmt = $db->conn->prepare("SELECT Email FROM C_Client.dbo.Clientes WHERE Email=?");
        $stmt->bindValue(1, $email, PDO::PARAM_STR);
        $stmt->execute();
        if(!$stmt){
            $errors[] = 'Falha ao verificar o Endereço de E-Mail.';
        }
        elseif($data=$stmt->fetch(PDO::FETCH_NUM)){
            $errors[] = 'Este endereço de e-mail já está em uso. Por favor utilize outro.';
        }
    }

    if(empty($nome)){
        $errors[] = 'Por favor insira um nome válido.';
    }else if(strlen($nome) < 4 || strlen($nome) > 64){
        $errors[] = 'O nome deve conter entre 4-64 caracteres.';
    }

    if(count($errors) == 0){
        $userip = $_SERVER['REMOTE_ADDR'];
        $stmt   =   $db->conn->prepare("INSERT INTO C_Client.dbo.Clientes (UsuarioID, Nome, Password, Email, Sexo)VALUES (?,?,?,?,?)");
        $stmt->bindValue(1, $usuario, PDO::PARAM_STR);
        $stmt->bindValue(2, $nome, PDO::PARAM_STR);
        $stmt->bindValue(3, $password, PDO::PARAM_STR);
        $stmt->bindValue(4, $user_ip, PDO::PARAM_STR);
        $stmt->bindValue(5, $email, PDO::PARAM_STR);
        $stmt->bindValue(6, $sexo, PDO::PARAM_STR);

        if($stmt->execute()){
            $success = "{$nome} sua conta foi criada com sucesso!";
        }else{
            $errors[] = 'Falha ao criar uma conta, por favor tente mais tarde!';
        }
    }
}
?>
  <!DOCTYPE html>
  <html lang="pt-br">

  <head>
    <title>Country</title>
    <meta charset="utf-8" ">
    <meta name="viewport " content="width=device-width, inital-scale1.0 ">
    <link rel="icon " href="img/favicon.png ">
    <!-- MATERIALIZER CSS -->
    <link rel="stylesheet " href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css ">
    <!-- CUSTOM CSS -->
    <link rel="stylesheet " href="css/custom.css ">
    <!-- DOWN-CONTENT CSS -->
    <link rel="stylesheet " href="css/down-content.css ">
    <!-- TOOLTIPSTER CSS -->
    <link rel="stylesheet " href="css/tooltipster.bundle.css ">
    <link rel="stylesheet " href="css/tooltipster-follower.css ">
    <!-- GOOGLE ICONS -->
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons " rel="stylesheet ">
    <!-- GOOGLE FONTS -->
    <link href="//fonts.googleapis.com/css?family=Cinzel+Decorative:400,700 " rel="stylesheet ">
    <!-- - -->
    <link rel="stylesheet " href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css ">


</head>
<body>

    <div id="top " class="navbar ">
        <?php include "top.php " ?>
    </div>

<div id="main " class="row container banner col s12 center ">
    <div class="logo ">
        <img src="img/favicon.png ">
    </div>

    <div class="panel ">
    <div class="top "></div>
    <div class="body ">
        <div class="title ">Cadastro
            <br>
            <div class="separador ">
                    <img src="img/panel/separador-horizontal.png ">
            </div>
        </div>
        <p>Bem Vindo</p>

        <form method="post ">

        <?php if(count($errors)){ ?>
                        <ul id="error ">
                        <?php foreach($errors as $error){ ?>
                            <li><?php echo $error; ?></li>
                        <?php } ?>
                        </ul>
                    <?php }else{
                        ?><div class="success "><?php echo $success; ?></div><?
                    } ?>


        <div class="input-field ">
            <i class="material-icons prefix icon-color-ca ">person</i>
            <input value="<?php if(isset($_POST[ 'nome'])){ echo $_POST[ 'nome']; } ?>" type="texto" name="nome" id="nome" maxlength="64" placeholder="NOME" required="required"/>
    </div>

    <div class="input-field">
      <i class="material-icons prefix icon-color-ca">person</i>
      <input value="<?php if(isset($_POST['usuario'])){ echo $_POST['usuario']; } ?>" type="texto" name="usuario" id="usuario" maxlength="16" placeholder="USÚARIO" required="required" />
    </div>

    <div class="input-field">
      <i class="material-icons prefix icon-color-ca">lock</i>
      <input value="<?php if(isset($_POST['password'])){ echo $_POST['password']; } ?>" type="password" name="password" id="password" maxlength="16" placeholder="SENHA" onfocus="removeDisabled()" required="required" pattern="(?=^.{8,16}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$"
      />

    </div>

    <div class="input-field">
      <i class="material-icons prefix icon-color-ca">repeat</i>
      <input value="<?php if(isset($_POST['password2'])){ echo $_POST['password2']; } ?>" type="password" name="password2" id="password2" maxlength="16" placeholder="REPITA A SENHA" required="required" pattern="(?=^.{8,16}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$"
      />

    </div>

    <div class="input-field">
      <i class="material-icons prefix icon-color-ca">email</i>
      <input value="<?php if(isset($_POST['email'])){ echo $_POST['email']; } ?>" type="texto" name="email" id="email" maxlength="64" placeholder="E-MAIL" required="required" />

    </div>

    <center>
      <select class="browser-default personalizar-select" name="sexo" id="sexo">
        <option value="">Sexo</option>
        <option value="M">Masculino</option>
        <option value="F">Feminino</option>
        <option value="O">Outro</option>
      </select>
    </center>



    <input type="reset" name="reset" value="Limpar" />
    <input type="submit" name="submit" value="Criar Conta" />
    </form>
    </div>
    <div class="bottom"></div>
    </div>
    </div>
    <div class="divider-footer"></div>

    <footer id="rodape">
      <div class="Pane Pane--dirtLight Pane--bgBottom bordered">
        <div class="Pane-bg">
          <div class="Pane-overlay"></div>
        </div>
        <div class="Pane-content">
          <div class="gutter-normal gutter-vertical">
            <div class="SocialLinks SocialLinks--wow">
              <div class="SocialLinks-title FooterText">2019 &copy; Country Todos os Direitos Reservados</div>
            </div>
          </div>
        </div>
      </div>
    </footer>
    </div>


    <!-- JQUERY JS -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <!-- MATERIALIZE JS -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
    <!-- - -->
    <script type="text/javascript" src="https://rawgit.com/iamceege/tooltipster/4.2.5/dist/js/tooltipster.bundle.min.js"></script>
    <!-- - -->
    <script type="text/javascript" src="https://rawgit.com/louisameline/tooltipster-follower/0.1.5/dist/js/tooltipster-follower.min.js"></script>
    <!-- - -->
    <script type="text/javascript" src="js/tooltip.js"></script>


    <!-- sidenav -->
    <script type="text/javascript">
      document.addEventListener('DOMContentLoaded', function() {
        var elems = document.querySelectorAll('.sidenav');
        var instances = M.Sidenav.init(elems, options);
      });

      $(document).ready(function() {
        $('.sidenav').sidenav();
      });
    </script>

    <!-- DOMContent -->
    <script type="text/javascript">
      document.addEventListener('DOMContentLoaded', function() {
        var elems = document.querySelectorAll('.dropdown-trigger');
        var instances = M.Dropdown.init(elems, options);
      });

      $('.dropdown-trigger').dropdown();
    </script>

    <!-- DropDown -->
    <script>
      $('.dropdown-button').dropdown({
        container: document.body
      });

      $(document).ready(function() {
        $('.sidenav').sidenav();
        $('.collapsible').collapsible();
        $('.tooltipped').tooltip();
        $('.modal').modal();
      }); // end of document ready
    </script>

    <script type="text/javascript">
      $(document).ready(function(e) {
        $('form[name=reg_form]').process_reg_form();
      });
    </script>

    <!-- select -->
    <script type="text/javascript">
      document.addEventListener('DOMContentLoaded', function() {
        var elems = document.querySelectorAll('select');
        var instances = M.FormSelect.init(elems, options);
      });

      $(document).ready(function() {
        $('select').formSelect();
      });
    </script>

    <script type="text/javascript">
      /*  jQuery Nice Select - v1.0
          https://github.com/hernansartorio/jquery-nice-select
          Made by Hernán Sartorio  */
      ! function(e) {
        e.fn.niceSelect = function(t) {
          function s(t) {
            t.after(e("<div></div>").addClass("nice-select").addClass(t.attr("class") || "").addClass(t.attr("disabled") ? "disabled" : "").attr("tabindex", t.attr("disabled") ? null : "0").html('<span class="current"></span><ul class="list"></ul>'));
            var s = t.next(),
              n = t.find("option"),
              i = t.find("option:selected");
            s.find(".current").html(i.data("display") || i.text()), n.each(function(t) {
              var n = e(this),
                i = n.data("display");
              s.find("ul").append(e("<li></li>").attr("data-value", n.val()).attr("data-display", i || null).addClass("option" + (n.is(":selected") ? " selected" : "") + (n.is(":disabled") ? " disabled" : "")).html(n.text()))
            })
          }
          if ("string" == typeof t) return "update" == t ? this.each(function() {
            var t = e(this),
              n = e(this).next(".nice-select"),
              i = n.hasClass("open");
            n.length && (n.remove(), s(t), i && t.next().trigger("click"))
          }) : "destroy" == t ? (this.each(function() {
            var t = e(this),
              s = e(this).next(".nice-select");
            s.length && (s.remove(), t.css("display", ""))
          }), 0 == e(".nice-select").length && e(document).off(".nice_select")) : console.log('Method "' + t + '" does not exist.'), this;
          this.hide(), this.each(function() {
            var t = e(this);
            t.next().hasClass("nice-select") || s(t)
          }), e(document).off(".nice_select"), e(document).on("click.nice_select", ".nice-select", function(t) {
            var s = e(this);
            e(".nice-select").not(s).removeClass("open"), s.toggleClass("open"), s.hasClass("open") ? (s.find(".option"), s.find(".focus").removeClass("focus"), s.find(".selected").addClass("focus")) : s.focus()
          }), e(document).on("click.nice_select", function(t) {
            0 === e(t.target).closest(".nice-select").length && e(".nice-select").removeClass("open").find(".option")
          }), e(document).on("click.nice_select", ".nice-select .option:not(.disabled)", function(t) {
            var s = e(this),
              n = s.closest(".nice-select");
            n.find(".selected").removeClass("selected"), s.addClass("selected");
            var i = s.data("display") || s.text();
            n.find(".current").text(i), n.prev("select").val(s.data("value")).trigger("change")
          }), e(document).on("keydown.nice_select", ".nice-select", function(t) {
            var s = e(this),
              n = e(s.find(".focus") || s.find(".list .option.selected"));
            if (32 == t.keyCode || 13 == t.keyCode) return s.hasClass("open") ? n.trigger("click") : s.trigger("click"), !1;
            if (40 == t.keyCode) {
              if (s.hasClass("open")) {
                var i = n.nextAll(".option:not(.disabled)").first();
                i.length > 0 && (s.find(".focus").removeClass("focus"), i.addClass("focus"))
              } else s.trigger("click");
              return !1
            }
            if (38 == t.keyCode) {
              if (s.hasClass("open")) {
                var l = n.prevAll(".option:not(.disabled)").first();
                l.length > 0 && (s.find(".focus").removeClass("focus"), l.addClass("focus"))
              } else s.trigger("click");
              return !1
            }
            if (27 == t.keyCode) s.hasClass("open") && s.trigger("click");
            else if (9 == t.keyCode && s.hasClass("open")) return !1
          });
          var n = document.createElement("a").style;
          return n.cssText = "pointer-events:auto", "auto" !== n.pointerEvents && e("html").addClass("no-csspointerevents"), this
        }
      }(jQuery);

      $(document).ready(function() {
        $('.personalizar-select').niceSelect();
      });
    </script>

    </body>

  </html>
  • Man thank you very much.

  • For nothing! Good luck with the project :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.