-
-
Save siathalysedI/6549641 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 | |
| //======================================================================\\ | |
| // Script Ofusme Beta - Autor : ElJeshuuOk \\ | |
| // Copyright © 2013 - 2014 ElJeshuuOk- Todos Los Derechos Reservados. \\ | |
| // Programado en Programación Orientado a objetos. \\ | |
| //======================================================================\\ | |
| class conexion | |
| { | |
| private $servidor; | |
| private $usuario; | |
| private $password; | |
| private $bd; | |
| private $database; | |
| public function __construct($servidor= "localhost", $usuario = "root", $password = "", $bd = "") | |
| { | |
| $this->servidor=$servidor; | |
| $this->usuario=$usuario; | |
| $this->password=$password; | |
| $this->bd=$bd; | |
| $this->database = new mysqli($servidor, $usuario, $password, $bd); | |
| if ($this->database->connect_error) { | |
| die("Error (" . $this->database->connect_errno . ") ". $this->database->connect_error); | |
| } | |
| } | |
| public function getConexion() | |
| { | |
| return $this->database; | |
| } | |
| public function close() | |
| { | |
| $this->database->close(); | |
| } | |
| } | |
| /* registro de usuarios */ | |
| class registro | |
| { | |
| var $nombre; | |
| var $apellido; | |
| var $usuario; | |
| var $contrasena; | |
| var $email; | |
| public function tratandovariables() | |
| { | |
| /* Eliminando Caracteres Especiales */ | |
| $usuario = htmlspecialchars(strip_tags($_POST['usuario'])); | |
| $contrasena = htmlspecialchars($_POST['contrasena']); | |
| $email = htmlspecialchars(strip_tags($_POST['email'])); | |
| $nombre = htmlspecialchars(strip_tags($_POST['nombre'])); | |
| if (preg_match("/^[a-zA-Z0-9\-_]{3,20}$/", $usuario)) | |
| { | |
| /* Asignando Valor */ | |
| $this->usuario = $usuario; | |
| $this->contrasena = md5($contrasena); | |
| $this->email = $email; | |
| $this->nombre = $nombre; | |
| } | |
| else | |
| { | |
| echo "El nombre de usuario no es válido<br>"; | |
| exit; | |
| } | |
| } | |
| public function registro() | |
| { | |
| $this->tratandovariables(); | |
| /* Conectando la Base de Datos */ | |
| conexion(); | |
| /* Comprobando si existe el usuario */ | |
| $check = sprintf("select usuarios from usuario where usuario = '%s'", $this->usuario); | |
| $qry = mysql_query($check); | |
| /* La compracion */ | |
| if (mysql_num_rows($qry)) | |
| { | |
| echo "Lo sentimos, el nombre de usuario ya esta registrado.<br />"; | |
| mysql_free_result($qry); | |
| exit; | |
| } else | |
| { | |
| /* Insertar Datos Al Registros*/ | |
| $insert = sprintf("insert into usuarios (id,nombre,apellido,usuario,contrasena,email) values (NULL, '%s', '%s', '%s', '%s')", $this->nombre, $this->apellido, $this->usuario ,$this->contrasena, $this->email); | |
| $qry = mysql_query($insert); | |
| if(mysql_affected_rows()) | |
| { | |
| echo "El Usuario $this->usuario se Registro Correctamente"; | |
| } | |
| else | |
| { | |
| echo "Error Ingresando datos"; | |
| } | |
| exit; | |
| } | |
| } | |
| } | |
| /* Eleminar usuario de la base de datos*/ | |
| $insert = sprintf( "DELETE FROM usuario WHERE id=?"); | |
| $qry = mysql_query($insert); | |
| ?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment