teste - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of teste.php

  1.  
  2. <script type="text/javascript">
  3. function validaCampo()
  4. {
  5. if(document.cadform.titulo.value=="")
  6. {
  7. alert("O Campo titulo é obrigatório!");
  8. return false;
  9. }
  10. else
  11. return true;
  12. }
  13.  
  14. if(document.cadform.mome.value=="")
  15. {
  16. alert("O Campo nome é obrigatório!");
  17. return false;
  18. }
  19. else
  20. return true;
  21. }
  22.  
  23.  
  24.  
  25. <!-- Fim do JavaScript que validará os campos obrigatórios! -->
  26. </script>
  27. depois eu vou criar o formulario assim
  28.  
  29. <form id="cadform" name="cadform" method="post" action="enviar.php" onsubmit="return validaCampo();">
  30.   <label for="titulo">Titulo</label>
  31.   <input name="titulo" type="text" id="titulo" size="40" />
  32.   
  33.     <label for="nome">Nome</label>
  34.   <input name="nome" type="text" id="nome" size="40" />
  35.   
  36.   <input type="submit" name="enviar" id="enviar" value="Submit"   />
  37. </form>
File Description
  • teste
  • PHP Code
  • 09 Feb-2021
  • 782 Bytes
You can Share it: