0

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
}
?>

Edited by designer2011: n/a

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by designer2011
0

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

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.