Jump to content

Php contact form


rhapsody

Recommended Posts

hey!I want to add "required fields" and "valid mail address" alert to my php code,my code is;<?php$field_name = $_POST['cf_name'];$field_email = $_POST['cf_email'];$field_message = $_POST['cf_message'];$mail_to = '_';$subject = 'Message from a site visitor '.$field_name;$body_message = 'From: '.$field_name."\n";$body_message .= 'E-mail: '.$field_email."\n";$body_message .= 'Message: '.$field_message;$headers = 'From: '.$field_email."\r\n";$headers .= 'Reply-To: '.$field_email."\r\n";$mail_status = mail($mail_to, $subject, $body_message, $headers);if ($mail_status) { ?><script language="javascript" type="text/javascript">alert('Your message has been sent. We will contact you shortly.');window.location = 'contact1.html';</script><?php}else { ?><script language="javascript" type="text/javascript">alert('Your message could not be delivered. You can contact us at(_)');window.location = 'contact1.html';</script><?php}?>any help will be appreciated...

Link to comment
Share on other sites

theres a function in php which check to see if the email is real or not, im not 100% sure on how to write it but i believe its

filter_var($email, FILTER_VALIDATE_EMAIL);

im not good with js so i use php to validate pretty much everything

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...