Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <header>
- <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
- <link href="style.css" rel="stylesheet" type="text/css"/>
- <title>M9 PT5 - Inscripcio</title>
- </header>
- <body>
- <?php
- $username = "root";
- $password = "Lolisimo1";
- $dbname = "M9PT5";
- $varnumdoc = $_POST['numdoc'];
- $varnom = $_POST['nom'];
- $varcog = $_POST['cognoms'];
- $vartlf = $_POST['tlf'];
- $conn = new mysqli("localhost", $username, $password, $dbname);
- $sql = "CREATE TABLE IF NOT EXISTS inscrits (
- ID INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
- DNI VARCHAR(9) NOT NULL,
- NOM VARCHAR(40) NOT NULL,
- COGNOMS VARCHAR(40) NOT NULL,
- TLF VARCHAR(9) NOT NULL,
- MAIL VARCHAR(50) NOTNULL,
- REG_DATE TIMESTAMP
- );";
- if ($conn->query($sql) === TRUE) {
- echo "Tabla INSCRITS creada.<br>";
- }
- else {
- echo "Error al crear la tabla " . $conn->error . "<br>";
- }
- $sql = "INSERT INTO inscrits (DNI,NOM,COGNOMS,TLF,MAIL) VALUES ($varnumdoc,$varnom,$varcog,$vartlf,$varmail);";
- if ($conn->query($sql) === TRUE) {
- echo "Dades guardades correctament";
- }
- else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- ?>
- <?php
- if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- $error = 0;
- if ($_POST['numdoc'] == '') {
- echo "Wrong: DNI";
- $error = '1';
- }else{
- function validacio_dni($DNI){
- $lletra = substr($DNI, -1);
- $nums = substr($DNI, 0, -1);
- if ( substr("TRWAGMYFPDXBNJZSQVHLCKE", $nums%23, 1) == $lletra && strlen($lletra) == 1 && strlen ($nums) == 8 ){
- }
- }
- }
- if ($_POST['nom'] == '') {
- echo "Missing: Nom";
- $error = '1';
- }
- if ($_POST['cognoms'] == '') {
- echo "Missing: Cognoms";
- $error = '1';
- }
- if($_POST['mail'] != $_POST['conmail']) {
- echo "Missmatch: E-mail";
- $error = '1';
- }elseif (($_POST['mail'] == '') or ($_POST['conmail'] == '')) {
- echo "Missing: E-mail";
- $error = '1';
- }
- if ($_POST['tlf'] < 9) {
- echo "Missmatch lenght: Tlf too short.";
- $error = '1';
- }
- function test_input($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- if(isset($_POST['numdoc'], $_POST['nom'], $_POST['cognoms'], $_POST['mail'], $_POST['conmail'], $_POST['tlf'])){
- if ($error != '1'){
- $pag = "validat.php";
- header ("location: ./validat.php");
- }else{
- echo "Something went wrong , fucker.";
- }
- }else{
- echo "Fil all the shit you dumbass.!";
- }
- }
- ?>
- <h2>Inscripció a la Santisima Isglesia del Macarró</h2>
- <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data" method="POST">
- <label> Número de document </label>
- <input type="text" name="numdoc" size="9" value="<?php if(isset($_POST['numdoc'])) echo $_POST['numdoc'];?>" required/><br>
- <label> Nom </label>
- <input type="text" name="nom" placeholder="Ramon" size="20" value="<?php if(isset($_POST['nom'])) echo $_POST['nom'];?>"/>
- <label> Cognoms </label>
- <input type="text" name="cognoms" placeholder="Macarron" size="50" value="<?php if(isset($_POST['cognoms'])) echo $_POST['cognoms'];?>" /><br>
- <label>Acepto les condicions</label>
- <input type="checkbox" name="name" value="cpp">Acepto<br>
- <label> Telèfon mòbil </label>
- <input type="tel" name="tlf" maxlength="9" placeholder="Telèfon" value="<?php if(isset($_POST['tlf'])) echo $_POST['tlf'];?>"/><br>
- <label> Correu electrònic </label>
- <input type="text" name="mail" placeholder="E-mail" value="<?php if(isset($_POST['mail'])) echo $_POST['mail'];?>"/><br>
- <label> Confirmació correu electrònic </label>
- <input type="text" name="conmail" placeholder="Confirmació E-mail" value="<?php if(isset($_POST['conmail'])) echo $_POST['conmail'];?>"/><br>
- <br>
- <label> <input type="reset" value="Borra"> <input type="submit" value="Envia"></label>
- <br>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement