Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("connection.php");
- if(isset($_POST['submit']))
- {
- if($_POST['nombre'] == '' or $_POST['apellido'] == '' or $_POST['email'] == '' or $_POST['usuario'] == '' or $_POST['pass'] == '')
- {
- echo "Debe llenar todo los datos por favor.";
- }else{
- $sql = 'SELECT * FROM monitores';
- $rec = mysqli_query($conexion,$sql);
- $verificar = 0;
- while($resultado = mysqli_fetch_object($rec))
- {
- if($resultado->usuario == $_POST['usuario'])
- {
- $verificar = 1;
- }
- }
- if($verificar == 0)
- {
- $nom = $_POST['nombre'];
- $apel = $_POST['apellido'];
- $mail = $_POST['email'];
- $usr = $_POST['usuario'];
- $pass = $_POST['pass'];
- $conexion->query("INSERT INTO monitores (nombre,apellido,email,usuario,contrasena) VALUES ('$nom','$apel','$mail','$usr','$pass')");
- mysqli_query($conexion,$sql);
- echo ' <script language="javascript">alert("Usuario registrado con éxito");</script> ';
- }
- }
- }
- ?>
- <?php
- $host="localhost";
- $hostuser="root";
- $hostpw="";
- $hostdb="fdj";
- $conexion = mysqli_connect($host, $hostuser, $hostpw);
- if (!$conexion) {
- die('No se ha podido conectar a la base de datos');
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement