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.
Result of php executing
Full code of Code error.php
- <?php
- $nameErr = $emailErr = $mobileErr = $ccErr = $expErr = "";
- $name = $email = $mobile = $ccNumber = $exp = "";
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- if (empty($_POST["cust[name]"])) {
- $nameErr = "Name is required";
- } else {
- $name = $_POST["cust[name]"];
- }
- echo $name;
- }
- ?>
- <html>
- <form name = "form" method="post">
- Name :
- <input value="<?php echo $name;?>" class = "input" type="text" required name="cust[name]" id = "cust-name">
- <span class="error">* <?php echo $nameErr;?></span>
- <input type="submit" name="submit" value="Order">
- </form>
- </html>