I've made a PHP contact form for my site and need help with a couple of things...

The form action links an external PHP script (scripts/contact-form-script.php) but is there a way I can have it so the PHP script for the form is contained within the same PHP file as my contact form (contact.php)?

I tried just putting the form code at the top of contact.php but the browser automatically reads the anti-spam re-direct, so maybe that needs revising too?

The second thing is, how can I make the Name, Email and Message fields mandatory? So if a user tries to submit the form and hasn't filled in one of the required fields and clicks submit, contact.php reloads with a message at the top of the form saying something like 'Complete the required fields' and highlights the relevant field with a red border?

You can then go on and have the basic_form_elements array contain the error message then you could simplify the error checking so that if count($errors) is > 0 then re-display the form. I hope I am not making things too convoluted for you, but arrays are a cornerstone of programming - and you'd do well to spend a good time investigating how best to use them.