Code error - 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 Code error.php

  1. <?php
  2.     $nameErr = $emailErr = $mobileErr = $ccErr = $expErr = "";
  3.         $name = $email = $mobile = $ccNumber = $exp = "";
  4.     if ($_SERVER["REQUEST_METHOD"] == "POST") {
  5.                 if (empty($_POST["cust[name]"])) {
  6.                         $nameErr = "Name is required";
  7.                 } else {
  8.                         $name = $_POST["cust[name]"];
  9.                 }
  10.         echo $name;
  11.     }
  12. ?>
  13.  
  14. <html>
  15.     <form name = "form" method="post">
  16.         
  17.         Name :
  18.                 <input value="<?php echo $name;?>" class = "input" type="text" required name="cust[name]" id = "cust-name">
  19.                 <span class="error">* <?php echo $nameErr;?></span>
  20.         <input type="submit"  name="submit"  value="Order">
  21.     </form>
  22.     
  23. </html>
File Description
  • Code error
  • PHP Code
  • 23 Oct-2019
  • 628 Bytes
You can Share it: