Last active
December 22, 2015 17:49
-
-
Save ElJeshuuOk/6509234 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| #==================================# | |
| # Ofusme - Version Beta 1.0 # | |
| # Programación ElJeshuuOk # | |
| #==================================# | |
| #==================================# | |
| # Conectar a la base de datos # | |
| #==================================# | |
| class Conectar | |
| { | |
| public static function con() | |
| { | |
| $conexion=mysql_connect("localhost","root",""); | |
| mysql_query("SET NAMES 'utf8'"); | |
| mysql_select_db(""); | |
| return $conexion; | |
| } | |
| } | |
| #==================================# | |
| # Registro De Usuarios # | |
| #==================================# | |
| class registro | |
| { | |
| var $nombre; | |
| var $apellido; | |
| var $usuario; | |
| var $email; | |
| var $contrasena; | |
| public function tratandovariables() | |
| { | |
| #==================================# | |
| # Eliminando Caracteres Especiales # | |
| #==================================# | |
| $nombre = htmlspecialchars(strip_tags($_POST['nombre'])); | |
| $apellido = htmlspecialchars(strip_tags($_POST['apellido'])); | |
| $usuario = htmlspecialchars(strip_tags($_POST['usuario'])); | |
| $email = htmlspecialchars(strip_tags($_POST['email'])); | |
| $contrasena = htmlspecialchars($_POST['contrasena']); | |
| $registro=new registro(); | |
| $registro->registro($nombre,$apellido,$usuario,$email,$contrasena); | |
| if (preg_match("/^[a-zA-Z0-9\-_]{3,20}$/", $usuario)) | |
| { | |
| #==================================# | |
| # Asignando Valor # | |
| #==================================# | |
| $this->nombre = $nombre; | |
| $this->apellido = $apellido; | |
| $this->usuario = $usuario; | |
| $this->email = $email; | |
| $this->contrasena = md5($contrasena); | |
| } | |
| else | |
| { | |
| echo "El nombre de usuario no es válido<br>"; | |
| exit; | |
| } | |
| } | |
| public function registro() | |
| { | |
| $this->tratandovariables(); | |
| #==================================# | |
| # Verificar si El Usuario Existe # | |
| #==================================# | |
| function verificar_si_el_usuario_existe() { | |
| $query = sprintf("SELECT `usuario` FROM `usuarios` WHERE `usuario` = '%s'", $this->db->real_escape_string(strtolower($this->usuario))); | |
| $resultado = $this->db->query($query); | |
| return ($resultado->num_rows == 0) ? 0 : 1; | |
| } | |
| #==================================# | |
| # Verificar si Email Existe # | |
| #==================================# | |
| function verificar_si_el_email_existe() { | |
| $query = sprintf("SELECT `email` FROM `usuarios` WHERE `email` = '%s'", $this->db->real_escape_string(strtolower($this->email))); | |
| $resultado = $this->db->query($query); | |
| return ($resultado->num_rows == 0) ? 0 : 1; | |
| } | |
| } | |
| } | |
| #======================================# | |
| # Insertar Usuarios a la base de datos # | |
| #======================================# | |
| function query() { | |
| $query = sprintf("INSERT into `usuarios` (`nombre`, `apellido`, `usuario`, `email`, `contrasena`) VALUES ('%s', '%s', '%s', '%s', 'default.png', '%s', 'default.png', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');", $this->db->real_escape_string($this->nombre), $this->db->real_escape_string($this->apellido) ,$this->db->real_escape_string($this->usuario), $this->db->real_escape_string($this->email), $this->db->real_escape_string($this->contrasena)); | |
| $this->db->query($query); | |
| // return ($this->db->query($query)) ? 0 : 1; | |
| } | |
| ?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment