Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.34 KB | None | 0 0
  1. <html>
  2. <header>
  3. <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  4. <link href="style.css" rel="stylesheet" type="text/css"/>
  5. <title>M9 PT5 - Inscripcio</title>
  6. </header>
  7. <body>
  8.  
  9. <?php
  10.  
  11. $username = "root";
  12. $password = "Lolisimo1";
  13. $dbname = "M9PT5";
  14.  
  15.  
  16.  
  17. $varnumdoc = $_POST['numdoc'];
  18. $varnom = $_POST['nom'];
  19. $varcog = $_POST['cognoms'];
  20. $vartlf = $_POST['tlf'];
  21.  
  22. $conn = new mysqli("localhost", $username, $password, $dbname);
  23.  
  24.  
  25. $sql = "CREATE TABLE IF NOT EXISTS inscrits (
  26. ID INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  27. DNI VARCHAR(9) NOT NULL,
  28. NOM VARCHAR(40) NOT NULL,
  29. COGNOMS VARCHAR(40) NOT NULL,
  30. TLF VARCHAR(9) NOT NULL,
  31. MAIL VARCHAR(50) NOTNULL,
  32. REG_DATE TIMESTAMP
  33. );";
  34.  
  35. if ($conn->query($sql) === TRUE) {
  36. echo "Tabla INSCRITS creada.<br>";
  37. }
  38. else {
  39. echo "Error al crear la tabla " . $conn->error . "<br>";
  40. }
  41.  
  42.  
  43. $sql = "INSERT INTO inscrits (DNI,NOM,COGNOMS,TLF,MAIL) VALUES ($varnumdoc,$varnom,$varcog,$vartlf,$varmail);";
  44.  
  45. if ($conn->query($sql) === TRUE) {
  46. echo "Dades guardades correctament";
  47. }
  48. else {
  49. echo "Error: " . $sql . "<br>" . $conn->error;
  50. }
  51.  
  52. ?>
  53.  
  54. <?php
  55. if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  56. $error = 0;
  57. if ($_POST['numdoc'] == '') {
  58. echo "Wrong: DNI";
  59. $error = '1';
  60. }else{
  61. function validacio_dni($DNI){
  62. $lletra = substr($DNI, -1);
  63. $nums = substr($DNI, 0, -1);
  64. if ( substr("TRWAGMYFPDXBNJZSQVHLCKE", $nums%23, 1) == $lletra && strlen($lletra) == 1 && strlen ($nums) == 8 ){
  65. }
  66. }
  67. }
  68.  
  69. if ($_POST['nom'] == '') {
  70. echo "Missing: Nom";
  71. $error = '1';
  72. }
  73.  
  74. if ($_POST['cognoms'] == '') {
  75. echo "Missing: Cognoms";
  76. $error = '1';
  77. }
  78.  
  79. if($_POST['mail'] != $_POST['conmail']) {
  80. echo "Missmatch: E-mail";
  81. $error = '1';
  82.  
  83. }elseif (($_POST['mail'] == '') or ($_POST['conmail'] == '')) {
  84. echo "Missing: E-mail";
  85. $error = '1';
  86. }
  87.  
  88. if ($_POST['tlf'] < 9) {
  89. echo "Missmatch lenght: Tlf too short.";
  90. $error = '1';
  91. }
  92. function test_input($data) {
  93. $data = trim($data);
  94. $data = stripslashes($data);
  95. $data = htmlspecialchars($data);
  96. return $data;
  97. }
  98.  
  99. if(isset($_POST['numdoc'], $_POST['nom'], $_POST['cognoms'], $_POST['mail'], $_POST['conmail'], $_POST['tlf'])){
  100.  
  101. if ($error != '1'){
  102. $pag = "validat.php";
  103. header ("location: ./validat.php");
  104. }else{
  105. echo "Something went wrong , fucker.";
  106. }
  107. }else{
  108. echo "Fil all the shit you dumbass.!";
  109. }
  110. }
  111. ?>
  112.  
  113.  
  114. <h2>Inscripció a la Santisima Isglesia del Macarró</h2>
  115.  
  116. <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data" method="POST">
  117.  
  118. <label> Número de document </label>
  119. <input type="text" name="numdoc" size="9" value="<?php if(isset($_POST['numdoc'])) echo $_POST['numdoc'];?>" required/><br>
  120.  
  121. <label> Nom </label>
  122. <input type="text" name="nom" placeholder="Ramon" size="20" value="<?php if(isset($_POST['nom'])) echo $_POST['nom'];?>"/>
  123.  
  124. <label> Cognoms </label>
  125. <input type="text" name="cognoms" placeholder="Macarron" size="50" value="<?php if(isset($_POST['cognoms'])) echo $_POST['cognoms'];?>" /><br>
  126.  
  127. <label>Acepto les condicions</label>
  128. <input type="checkbox" name="name" value="cpp">Acepto<br>
  129.  
  130. <label> Telèfon mòbil </label>
  131. <input type="tel" name="tlf" maxlength="9" placeholder="Telèfon" value="<?php if(isset($_POST['tlf'])) echo $_POST['tlf'];?>"/><br>
  132.  
  133. <label> Correu electrònic </label>
  134. <input type="text" name="mail" placeholder="E-mail" value="<?php if(isset($_POST['mail'])) echo $_POST['mail'];?>"/><br>
  135.  
  136. <label> Confirmació correu electrònic </label>
  137. <input type="text" name="conmail" placeholder="Confirmació E-mail" value="<?php if(isset($_POST['conmail'])) echo $_POST['conmail'];?>"/><br>
  138.  
  139. <br>
  140. <label> <input type="reset" value="Borra"> <input type="submit" value="Envia"></label>
  141. <br>
  142. </form>
  143.  
  144.  
  145.  
  146. </body>
  147. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement