Please help! Contact form doesn't send msgs.

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
Watch

RU

I'm out of domaining. ~RusselAccount Closed (Requested)
Impact
2,975
html code
Code:
<form action="contact.php" method="post">
<div class="form_details">
<input type="text" class="text" value="Name" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Name';}">
<input type="text" class="text" value="Email Address" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email Address';}">
<textarea value="Message" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Message';}">Message</textarea>
<div class="clearfix"> </div>
<div class="sub-button">
<input name="submit" type="submit" value="Send message">
</div>
</div>
</form>

contact.php
Code:
<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];

$mail_to = '[email protected]';
$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('Thank you for the message. We will contact you shortly.');
        window.location = 'index.html';
    </script>
<?php
}
else { ?>
    <script language="javascript" type="text/javascript">
        alert('Message failed. Please, send an email to [email protected]');
        window.location = 'contact_page.html';
    </script>
<?php
}
?>

Can anyone please help me.

Thanks.
 
Last edited:
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Looks like your input field names don't match the post values the php file is expecting ($cf_name, etc.) also have you set the recipient email ($mail_to ) to yours ;)?

Btw never use values people post in a form without sanitizing them!
 
0
Close
recipient email is not a real address.
 
0
Close
I suppose you should remove the javascript for basic testing first... and after it is working, then add the javascript at various places, one by one !
 
1
Close
input & textarea don't have name="" attributes.

Code:
input name="cf_name" 
input name="cf_email"  
textarea name="cf_message"
 
1
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back