Just wondering if anyone can help with making all the fields on my contact form a required field. I have added the coding for the contact form php.
Also will there be an adjustment to the coding for the website?

Thank you in advance for your help.

<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_phone = $_POST['cf_phone'];
$field_message = $_POST['cf_message'];

$mail_status = mail($mail_to, $subject, $body_message, $headers);

if ($mail_status) { ?>
	<script language="javascript" type="text/javascript">
		alert('Thank you for the message');
		window.location = 'index.html';
	</script>
<?php
}
else { ?>
	<script language="javascript" type="text/javascript">
		alert('Message failed. Please, send an email');
		window.location = 'index.html';
	</script>
<?php
}
?>

There is a couple of ways to do this and one of the most common ways is by java script. I uave on that when the user hits submit it goes to a page named process and that's when everything is done. If there are errors it will tell u to hit the back button. Anyway u do it u will have to modify the code. I can modify this code for u tomorrow and have it were it verifies the fields. Just let me know and i will had it for u around 5 pm central time

Thank you, that would be great.

At the moment the contact form is working, it works in php but it can be submitted empty without any information. I just want to make the name, email and message a required field, so that information has to be entered before it is submitted, if the required fields are not entered it should notify the visitor that the required fields have not been entered, and if the contact form has been completed a thank you message pops ups, which already happens now with or without any information entered.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.