Guest User

Untitled

a guest
Aug 21st, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.45 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Registration</title>
  6. <link rel="stylesheet" href="css/style1.css" />
  7. </head>
  8. <body>
  9.  
  10. <?php
  11. require('db.php');
  12. // If form submitted, insert values into the database.
  13.  
  14.  
  15. if (isset($_REQUEST['username'])){
  16. // removes backslashes
  17. $username = stripslashes($_REQUEST['username']);
  18. //escapes special characters in a string
  19. $username = mysqli_real_escape_string($con,$username);
  20.  
  21. $email = stripslashes($_REQUEST['email']);
  22. $email = mysqli_real_escape_string($con,$email);
  23.  
  24. $telefono = stripslashes($_REQUEST['telefono']);
  25. $telefono = mysqli_real_escape_string($con,$telefono);
  26.  
  27. $empresa = stripslashes($_REQUEST['empresa']);
  28. $empresa = mysqli_real_escape_string($con,$empresa);
  29.  
  30. $password = stripslashes($_REQUEST['password']);
  31. $password = mysqli_real_escape_string($con,$password);
  32.  
  33. $trn_date = date("Y-m-d H:i:s");
  34.  
  35. // validacion de usuario registrado
  36.  
  37. include 'db.php';
  38.  
  39. $buscarUsuario = "SELECT * FROM users WHERE email = '$_POST[email]' ";
  40. $result = $con ->query($buscarUsuario);
  41. $count = mysqli_num_rows($result);
  42.  
  43. if($count == 1) {header("Location: registration_duplicated.php");}
  44.  
  45. else{
  46.  
  47. $query = "INSERT into `users` (username, password, email, telefono, empresa, trn_date)
  48. VALUES ('$username', '".md5($password)."', '$email', '$telefono','$empresa', '$trn_date')";
  49.  
  50. $result = mysqli_query($con,$query);
  51.  
  52. if($result){header("Location: Registro_exitoso.php");}
  53.  
  54. }}
  55.  
  56. else{
  57. ?>
  58.  
  59. <div class="wrapper fadeInDown1">
  60. <div id="formContent">
  61.  
  62. <a href="login.php"><h2 class="inactive underlineHover"> Ingresar </h2></a>
  63. <h2 class="active"> Registrarte </h2>
  64.  
  65.  
  66. <form name="registration" action="" method="post">
  67.  
  68.  
  69. <input type="text" class="fadeIn regitration" name="username" placeholder="Usuario" required />
  70.  
  71. <input type="email" class="fadeIn regitration" name="email" placeholder="Correo" required />
  72.  
  73. <input type="password" class="fadeIn regitration" name="password" placeholder="Contraseña" required />
  74.  
  75. <input type="tel" class="fadeIn regitration" name="telefono" placeholder="Telefono" required />
  76.  
  77. <input type="text" class="fadeIn regitration" name="empresa" placeholder="Empresa" required />
  78.  
  79. <input type="submit" class="fadeIn regitration" name="submit" value="Registrarse" />
  80.  
  81. </form>
  82.  
  83.  
  84. </div>
  85. </div>
  86.  
  87.  
  88. <?php } ?>
  89. </body>
  90. </html>
  91.  
  92. <!DOCTYPE html>
  93. <html>
  94. <head>
  95. <meta charset="utf-8">
  96. <title>Registration</title>
  97. <link rel="stylesheet" href="css/style1.css" />
  98. </head>
  99. <body>
  100.  
  101. <?php
  102. require('db.php');
  103. // If form submitted, insert values into the database.
  104.  
  105.  
  106. if (isset($_POST['submit'])){
  107. // removes backslashes
  108. $username = stripslashes($_POST['username']);
  109. //escapes special characters in a string
  110. $username = mysqli_real_escape_string($con,$username);
  111.  
  112. $email = stripslashes($_POST['email']);
  113. $email = mysqli_real_escape_string($con,$email);
  114.  
  115. $telefono = stripslashes($_POST['telefono']);
  116. $telefono = mysqli_real_escape_string($con,$telefono);
  117.  
  118. $empresa = stripslashes($_POST['empresa']);
  119. $empresa = mysqli_real_escape_string($con,$empresa);
  120.  
  121. $password = stripslashes($_POST['password']);
  122. $password = mysqli_real_escape_string($con,$password);
  123.  
  124. $trn_date = date("Y-m-d H:i:s");
  125.  
  126. // validacion de usuario registrado
  127.  
  128. include 'db.php';
  129.  
  130. $buscarUsuario = "SELECT * FROM users WHERE email = '$email' ";
  131. $result = $con ->query($buscarUsuario);
  132. $count = mysqli_num_rows($result);
  133.  
  134. if($count > 0) {
  135.  
  136. header("Location: registration_duplicated.php");
  137.  
  138. }else{
  139.  
  140. $query = "INSERT into `users` (username, password, email, telefono, empresa, trn_date)
  141. VALUES ('$username', '".md5($password)."', '$email', '$telefono','$empresa', '$trn_date')";
  142.  
  143. $result = mysqli_query($con,$query);
  144.  
  145. if($result){
  146. header("Location: Registro_exitoso.php");
  147.  
  148. } else{
  149.  
  150. echo"hubo un error.mysqli_error($con)";
  151.  
  152.  
  153. }
  154. }
  155. ?>
  156.  
  157. <div class="wrapper fadeInDown1">
  158. <div id="formContent">
  159.  
  160. <a href="login.php"><h2 class="inactive underlineHover"> Ingresar </h2></a>
  161. <h2 class="active"> Registrarte </h2>
  162.  
  163.  
  164. <form name="registration" action="" method="post">
  165.  
  166.  
  167. <input type="text" class="fadeIn regitration" name="username" placeholder="Usuario" required />
  168.  
  169. <input type="email" class="fadeIn regitration" name="email" placeholder="Correo" required />
  170.  
  171. <input type="password" class="fadeIn regitration" name="password" placeholder="Contraseña" required />
  172.  
  173. <input type="tel" class="fadeIn regitration" name="telefono" placeholder="Telefono" required />
  174.  
  175. <input type="text" class="fadeIn regitration" name="empresa" placeholder="Empresa" required />
  176.  
  177. <input type="submit" class="fadeIn regitration" name="submit" value="Registrarse" />
  178.  
  179. </form>
  180.  
  181.  
  182. </div>
  183. </div>
  184.  
  185. </body>
  186. </html>
Add Comment
Please, Sign In to add comment