Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <head>
- <title>Universalistas</title>
- <meta charset="utf-8"/>
- <link rel="stylesheet" href="css/style.css"/>
- <link rel="shortcut icon" href="css/images/logo.png"/>
- </head>
- </body>
- <?php ob_start();
- include("conection.php");
- if(isset($_POST["send"]))
- {
- function validate_mail($mail)
- {
- if (preg_match("/^[A-Za-z0-9-_.+%]+@[A-Za-z0-9-.]+.[A-Za-z]{2,4}$/", $mail)) return true;
- else return false;
- }//Fin funcion validate_mail
- $no_blank = count_chars($_POST["user"], 1);
- if(!empty($no_blank[32])) echo "<script>alert('El campo usuario no debe contener espacios en blanco.');history.back();</script>";
- elseif(empty($_POST["user"])) echo "<script>alert('Ingresa tu usuario.');history.back();</script>";
- elseif(empty($_POST["password"])) echo "<script>alert('Ingresa una contraseña.');history.back();</script>";
- elseif(empty($_POST["name"])) echo "<script>alert('Ingresa tu nombre.');history.back();</script>";
- elseif(empty($_POST["last-name"])) echo "<script>alert('Ingresa tu apellido.');history.back();</script>";
- elseif($_POST["password"] != $_POST["rpassword"]) echo "<script>alert('Las contraseñas no coinciden.');history.back();</script>";
- elseif(!validate_mail($_POST["mail"])) echo "<script>alert('El e-mail es incorrecto.');history.back();</script>";
- else
- {
- $con = new mysqli("localhost", "universalistas", "u12345", "universalistas");
- $user = mysqli_real_escape_string($con, $_POST["user"]);
- $password = mysqli_real_escape_string($con, $_POST["password"]);
- $mail = mysqli_real_escape_string($con, $_POST["mail"]);
- $name = $_POST["name"];
- $lastname = $_POST["last-name"];
- $origin = $_POST["origin"];
- $area = $_POST["area"];
- $sql = mysqli_query($con, "SELECT user_name FROM user WHERE user_name='".$user."'");
- if(mysqli_num_rows($sql) > 0) echo "<script>alert('El usuario ya existe.');history.back();</script>";
- else
- {
- $password = md5($password); //Encriptacion md5
- $reg = mysqli_query($con, "INSERT INTO user (user_name, user_password, user_mail, name, last_name, origin, area)
- VALUES ('".$user."', '".$password."', '".$mail."', '".$name."', '".$lastname."', '".$origin."', '".$area."')");
- if($reg)
- {
- echo "<script>alert('Usuario registrado correctamente.');
- window.location.href = 'index.php';</script>";
- }
- else
- {
- echo"<script>alert('¡Ha ocurrido un error y no se registraron los datos!');
- window.location.href = 'index.php';</script>";
- }
- }
- }
- }
- else {}
- ob_end_flush() ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment