-1

First of all, yes I have seen familiar questions but I have no idea about PHP and my code was mostly copy and pasted by a tutorial. I was hoping for a more of a direct answer towards me then trying to figure it on a previously answered question.

I get this error when i go to my contact page " Fatal error: Call to undefined function test_input() in /home/precisioncne/public_html/form_process.php on line 14". My contact page has html and php. Contact page code: https://pastebin.com/7yAx59Bv

This is my form_process page which is receiving the error:

<?php 

ini_set('display_errors', 1);

$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$number = $_POST['number'];
$message = $_POST['message'];
$to = "email@email.com";
$subject = "New Email - Contact Form - Website";


$fname = test_input($_POST["fname"]);
    if (!preg_match("/^[a-zA-Z ]*$/",$fname)) {
        $nameErr = "Only letters and white space allowed"; 
    }

$lname = test_input($_POST["lname"]);
    if (!preg_match("/^[a-zA-Z ]*$/",$lname)) {
        $nameErr = "Only letters and white space allowed"; 
    }


$email = test_input($_POST["email"]);
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        $emailErr = "Invalid email format"; 
    }

mail ($to, $subject, $message, "From: " . $fname . $lname . $number);
echo "Your message has been sent!"; 

?>

Any help would be great thanks.

Aqorn
  • 1

1 Answers1

-1

test_input() is a function being called, but it hasn't been created. There is no built-in PHP function test_input(), so you need to make it and define what its function is.

  • Thank you. As I said I am really clueless when it comes to PHP. I went to W3 schools and found the code needed and it works. Still having some issues with the page not redirecting and "Your message has been sent!" is on the contact page even when I havent used the contact form, but I will work it out. :) – Aqorn Jun 21 '17 at 15:05