3v4l.org

run code in 300+ PHP versions simultaneously
<?php if(!empty($_POST["register-user"])) { /* Form Required Field Validation */ foreach($_POST as $key=>$value) { if(empty($_POST[$key])) { $error_message = "Todos los datos son obligatorios. All Fields are required"; break; } } /* Password Matching Validation */ if($_POST['password'] != $_POST['confirm_password']){ $error_message = 'Las claves deben ser iguales. Passwords should be same<br>'; } /* Email Validation */ if(!isset($error_message)) { if (!filter_var($_POST["EMAIL"], FILTER_VALIDATE_EMAIL)) { $error_message = "El email no es válido. Invalid Email Address"; } } /* Validation to check if gender is selected */ if(!isset($error_message)) { if(!isset($_POST["GENERO"])) { $error_message = " Todos los datos son obligatorios. All Fields are required"; } } /* Validation to check if Terms and Conditions are accepted */ if(!isset($error_message)) { if(!isset($_POST["terms"])) { $error_message = "Debe aceptar las condiciones del registro"; } } if(!isset($error_message)) { require_once("dbcontroller.php"); $db_handle = new DBController(); $query = "INSERT INTO registered_users (CI, password, NOMBRE, APELLIDO, GENERO, FECHA-NACIMIENTO, DIRECCION, CP, CIUDAD, PAIS, CELULARA, CELULARB, EMAIL) VALUES ('" . $_POST["CI"] . "' , '" . $_POST["password"] . "' , '" . $_POST["NOMBRE"] . "' , '" . $_POST["APELLIDO"] . "' , '" . $_POST["GENERO"] . "' , ['" . $_POST["FECHA-NACIMIENTO"] . "' , '" . $_POST["DIRECCION"] . "' , '" . $_POST["CP"] . "' , '" . $_POST["CIUDAD"] . "' , '" . $_POST["PAIS"] . "' , '" . $_POST["CELULARA"] . "' , '" . $_POST["CELULARB"] . "' , '" . $_POST["EMAIL"] . "')"; $result = $db_handle->insertQuery($query); if(!empty($result)) { $error_message = ""; $success_message = "Felicitaciones. Has completado el registro correctamente. Congratulations. You have registered successfully!"; unset($_POST); } else { $error_message = "No se completado el registro. Vuelve a intentarlo. Problem in registration. Try Again!"; } } } ?> <html> <head> <title>Registro de Socios</title> <style> body{ width:610px; font-family:calibri; } .error-message { padding: 7px 10px; background: #fff1f2; border: #ffd5da 1px solid; color: #d6001c; border-radius: 4px; } .success-message { padding: 7px 10px; background: #cae0c4; border: #c3d0b5 1px solid; color: #027506; border-radius: 4px; } .demo-table { background: #d9eeff; width: 100%; border-spacing: initial; margin: 2px 0px; word-break: break-word; table-layout: auto; line-height: 1.8em; color: #333; border-radius: 4px; padding: 20px 40px; } .demo-table td { padding: 15px 0px; } .demoInputBox { padding: 10px 30px; border: #a9a9a9 1px solid; border-radius: 4px; } .btnRegister { padding: 10px 30px; background-color: #3367b2; border: 0; color: #FFF; cursor: pointer; border-radius: 4px; margin-left: 10px; } </style> </head> <body> <form name="frmRegistration" method="post" action=""> <table border="0" width="500" align="center" class="demo-table"> <?php if(!empty($success_message)) { ?> <div class="success-message"><?php if(isset($success_message)) echo $success_message; ?></div> <?php } ?> <?php if(!empty($error_message)) { ?> <div class="error-message"><?php if(isset($error_message)) echo $error_message; ?></div> <?php } ?> <tr> <td colspan="2" align="center"><strong>Datos de Acceso</strong></td> </tr> <tr> <td>CI</td> <td><input type="text" class="demoInputBox" name="CI" value="<?php if(isset($_POST['CI'])) echo $_POST['CI']; ?>"></td> </tr> <tr> <td>Password</td> <td><input type="password" class="demoInputBox" name="password" value=""></td> </tr> <tr> <td>Confirmar Password</td> <td><input type="password" class="demoInputBox" name="confirm_password" value=""></td> </tr> <tr> <td colspan="2" align="center"><strong>Datos Personales</strong></td> </tr> <tr> <td>Nombre</td> <td><input type="text" class="demoInputBox" name="NOMBRE" value="<?php if(isset($_POST['NOMBRE'])) echo $_POST['NOMBRE']; ?>"></td> </tr> <tr> <td>Apellido</td> <td><input type="text" class="demoInputBox" name="APELLIDO" value="<?php if(isset($_POST['APELLIDO'])) echo $_POST['APELLIDO']; ?>"></td> </tr> <tr> <td>Género</td> <td><input type="radio" name="GENERO" value="MASCULINO" <?php if(isset($_POST['GENERO']) && $_POST['GENERO']=="MASCULINO") { ?>checked<?php } ?>> MASCULINO <input type="radio" name="GENERO" value="FEMENINO" <?php if(isset($_POST['GENERO']) && $_POST['GENERO']=="FEMENINO") { ?>checked<?php } ?>> FEMENINO </td> </tr> <tr> <td>Fecha de Nacimiento</td> <td><input type="text" class="demoInputBox" name="FECHA-NACIMIENTO" value="<?php if(isset($_POST['FECHA-NACIMIENTO'])) echo $_POST['FECHA-NACIMIENTO']; ?>"></td> </tr> <tr> <td colspan="2" align="center"><strong>Datos de Contacto</strong></td> </tr> <tr> <td>Dirección</td> <td><input type="text" class="demoInputBox" name="DIRECCION" value="<?php if(isset($_POST['DIRECCION'])) echo $_POST['DIRECCION']; ?>"></td> </tr> <tr> <td>CP</td> <td><input type="text" class="demoInputBox" name="CP" value="<?php if(isset($_POST['CP'])) echo $_POST['CP']; ?>"></td> </tr> <tr> <td>Ciudad</td> <td><input type="text" class="demoInputBox" name="CIUDAD" value="<?php if(isset($_POST['CIUDAD'])) echo $_POST['CIUDAD']; ?>"></td> </tr> <tr> <td>País</td> <td><input type="text" class="demoInputBox" name="PAIS" value="<?php if(isset($_POST['PAIS'])) echo $_POST['PAIS']; ?>"></td> </tr> <tr> <td>Celular 1</td> <td><input type="text" class="demoInputBox" name="CELULARA" value="<?php if(isset($_POST['CELULARA'])) echo $_POST['CELULARA']; ?>"></td> </tr> <tr> <td>Celular 2</td> <td><input type="text" class="demoInputBox" name="CELULARB" value="<?php if(isset($_POST['CELULARB'])) echo $_POST['CELULARB']; ?>"></td> </tr> <tr> <td>Email</td> <td><input type="text" class="demoInputBox" name="EMAIL" value="<?php if(isset($_POST['EMAIL'])) echo $_POST['EMAIL']; ?>"></td> </tr> <tr> <td colspan="2" align="center"><strong>Datos de Afiliación</strong></td> </tr> <tr> <td>Número de Socio</td> <td>&nbsp;</td> </tr> <tr> <td>Fecha de Ingreso</td> <td>&nbsp;</td> </tr> <tr> <td>Vencimiento de Membresía</td> <td>&nbsp;</td> </tr> <tr> <td>Categoría</td> <td>&nbsp;</td> </tr> <tr> <td>Estado de Afiliación</td> <td>&nbsp;</td> </tr> <tr> <td colspan=2> <input type="checkbox" name="terms"> Al registrarme acepto las condiciones de afiliación al club <input type="submit" name="register-user" value="Registrarme" class="btnRegister"></td> </tr> </table> </form> </body></html>

preferences:
64.78 ms | 402 KiB | 5 Q