Advertisement
ph4x35ccb

valida formulario linha 19 php

Apr 3rd, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Validaçao Formulario</title>
  5. </head>
  6. <body>
  7. <fieldset size="300">
  8.     <legend>Cadastro</legend>
  9.     <form action="valida_cadastro.php" method="POST">
  10.         Nome: <input type="text" size="30" name="nome"><br>
  11.         Email: <input type="text" size="30" name="email"><br>
  12.         Twitter: <input type="text" size="30" name="twitter"><br>
  13.         <button>Enviar</button>
  14.     </form>
  15. </fieldset>
  16. </body>
  17. </html>
  18.  
  19. <?php
  20. $nome = trim($_POST['nome']);
  21. $email = trim($_POST['email']);
  22. $twiter =strtolower(trim($_POST['twitter']));
  23.  
  24. if(!preg_match('/^[^0-9]{2,80}$/i',$nome)){
  25.     exit('Formato incorreto');
  26. }
  27. $emailregex=<<<REGEXEMAIL
  28. /^[^0-9][a-z0-9_]+([.][a-z0-9_]+)*[@][a-z0-9-_]+([.][a-z0-9]{2,3})*[.][a-z]{2,3}$/
  29. REGEXEMAIL;
  30.  
  31. if(!preg_match($emailregex, $email)){
  32.     exit('Email invalido');
  33. }
  34. if(!preg_match('/^@[a-z_]{1,15}/', $twiter)){
  35.     exit('TwitterInvalido');
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement