Hello, Array() is being printed above my contact form and cannot work out why. Here is my code HTML <div class="footer-section-right"> <?php include('form_process.php'); ?> <form method="post" action="<?= $_SERVER['PHP_SELF']; ?>"> <input class="input1" type="text" placeholder="Name" name="name"> <input class="input1" type="text" placeholder="Email" name="email"> <input class="input1" type ="text" placeholder="Subject" name="subject"> <input class="message" type="text" placeholder="Message" name="message"> <input class="submit" type="submit" value="Send"> </form> </div> </div> </footer> HTML: PHP: <?php print_r($_POST); // define variables and set to empty values $name_error = $email_error = /*$phone_error = $url_error = */""; $name = $email = /*$phone*/$subject = $message/* = $url */= ""; //form is submitted with POST method if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $name_error = "Name is required"; } else { $name = test_input($_POST["name"]); //Check if name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $name_error = "Only letters and white space allowed"; } } if (empty($POST["email"])) { $email_error = "Email is required"; } else { $email = test_input($_POST["email"]); //check if e-mail address is well-formed if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $email_error = "Invalid email format"; } } /* if (empty($_POST["phone"])) { $phone_error = "Phone is required"; } else { $phone = test_input($_POST["phone"]); //Check if phone is well-formed if (!preg_match("/^(\d[\s-]?)?[\(\[\s-]{0,2}?\d{3}[\)\]\s-]{0,2}?]d{3}[\s-]?]d{4}$/i",$phone)) { $phone_error = "Invalid phone number"; } } if (empty($_POST["url"])){ $url_error = ""; } else { $url = test_input($_POST["url"]); // Check if URL address syntax is valid (this regular expression also allows dashes in the URL) if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.:]*[-a-z0-9+&@#\/%=~_|]/i",$url)) { $url_error = "Invalid URL"; } } */ if (empty($_POST["subject"])) { $subject = ""; } else { $subject = test_input($_POST["subject"]); } if (empty($_POST["message"])) { $message = ""; } else { $message = test_input($_POST["message"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } PHP: I am following a youtube video to get my contact form working so far we are testing the PHP to get it to print above the contact form which seems to be working. However there is an Array() error appear above it. I'm not too sure why? Any help would be appreciated.
On line 3 in your PHP file you're telling it to print out your $_POST array. Try removing that, and see how it behaves.
That seemed to have fixed the array error. Thanks. However, if I would like to test it to print to the page is it suppose to have 'Array()'? Regards Chris
Where's your fieldset? Your label? Shouldn't the message be a textarea not an input? If you used a textarea instead of input and button instead of input for the submit, you could axe all the pointless classes. ... and FFS http://lmgtfy.com/?q=placeholder+is+not+a+label