<?php include '../includes/insert/insert_usuario.php'; ?>
<form class="form-horizontal style-form" method="post">
<div class="form-group">
<label class="col-sm-2 col-sm-2 control-label"><b>Nombre</b></label>
<div class="col-sm-3">
<input type="text" class="form-control" minlength="3" name="name">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 col-sm-2 control-label"><b>Correo</b></label>
<div class="col-sm-3">
<input type="email" class="form-control grey" name="email">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 col-sm-2 control-label"><b>Contraseña</b></label>
<div class="col-sm-3">
<input type="password" class="form-control grey" minlength="5" name="password">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 col-sm-2 control-label"><b>Confirmar contraseña</b></label>
<div class="col-sm-3">
<input type="password" class="form-control grey" minlength="5" name="cPassword">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 col-sm-2 control-label"></label>
<div class="col-sm-9">
<button class="btn btn-primary" name="submit" type="submit"><i class="fa fa-floppy-o"></i> GUARDAR</button>
</div>
</div>
</form>
form
PHP (insert_usuario.php)
<?php
$msg = "";
if (isset($_POST['submit'])) {
$con = new mysqli('localhost', 'root', '', 'carreteras');
$name = $con->real_escape_string($_POST['name']);$_POST['name'];
$email = $con->real_escape_string($_POST['email']);$_POST['email'];
$password = $con->real_escape_string($_POST['password']);$_POST['password'];
$cPassword = $con->real_escape_string($_POST['cPassword']);$_POST['cPassword'];
if ($password != $cPassword)
$msg = "¡Las contraseñas no coinciden!";
else {
$hash = password_hash($password, PASSWORD_BCRYPT);
$con->query("INSERT INTO users (name,email,password) VALUES ('$name', '$email', '$hash')");
$msg = "¡Usuario registrado con éxito!";
}
}
?>