Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

php contact form

General discussions related to php

Moderators: macek, egami, gesf

php contact form

Postby rhapsody » Fri Nov 16, 2012 3:45 am

hey!

I want to add "required fields" 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... :help:
rhapsody
New php-forum User
New php-forum User
 
Posts: 1
Joined: Fri Nov 16, 2012 3:43 am

Return to PHP General

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.