Index.html - 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 Index.html.php

  1. <html>
  2. <head>
  3. <title>PHP Form</title>
  4.  
  5. <style>
  6. .error {color: #FF0000;}
  7. </style>
  8.  
  9. </head>
  10. <body>
  11.  
  12. <h2>Testing Form Validations in PHP</h2>
  13. <p>This sign implies => <span class="error">* required field</span></p>
  14. <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">  
  15.  
  16. <label for="name">Username:</label><br>
  17. <input type="text" name="name" value="Name"><span class="error">* </span>
  18. <br><br>
  19.  
  20. <label for="email">Email:</label><br>
  21. <input type="email" name="email" value="[email protected]"><span class="error">* </span>
  22. <br><br>
  23.  
  24. <label for="website">Website:</label><br>
  25. <input type="text" name="website" value="www.abc.com"><span class="error">* </span>
  26. <br><br>
  27.  
  28. <label for="feedback">Feedback:</label><br>
  29. <textarea name="feedback" rows="5" cols="40">Add Feedback here</textarea>
  30. <br><br>
  31.  
  32. <label for="gender">Gender:</label><br>
  33. <input type="radio" name="gender" value="female" checked>Female
  34. <input type="radio" name="gender" value="male">Male
  35. <input type="radio" name="gender" value="other">Other
  36. <br><br>
  37.  
  38. <input type="submit" name="submit" value="Submit">  
  39. </form>
  40.  
  41. <?php
  42. echo "<h2>Your Input:</h2>";
  43. echo $name;
  44. echo "<br>";
  45. echo $email;
  46. echo "<br>";
  47. echo $website;
  48. echo "<br>";
  49. echo $feedback;
  50. echo "<br>";
  51. echo $gender;
  52. ?>
  53.  
  54. </body>
  55. </html>
  56.