Hey all,
I’m new to this forum and this is my first post, so go easy on me.
I have three files working together (or at least trying to), index.php, contact-form.js, send.php
I have a form on index.php and my goal is to have it email the info to my email address. I have it working where I receive the email, and it tells me the email address it’s from, but the Name and Message don’t appear in the email. I know I have a problem with send.php
Can anyone help? Here is my code for the three files:
>>>>>>
index.php<<<<<<<<<<
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “
<html xmlns=”
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<title></title>
<script type=”text/javascript” src=”
<link rel=”stylesheet” href=”
</head>
<body>
<div id=”content”>
<div id=”bottom”>
<div id=”main-content”>
<div class=”col1″>
<h3 class=”solo”>Send Us a Message</h3>
<p>Effective dialogue requires open lines of communication. Please fill out the form so we can keep in touch. Or, just call or email us directly if you prefer.</p>
<!–
Effective dialogue requires open lines of communication. Please fill out the form so we can keep in touch. Or, just call or email us directly if you prefer.
–>
<div id=”contact-form”>
<form name=”contact” action=””>
<ul>
<li>
<label for=”name” id=”label-name”>Name <span class=”error” id=”error-name”>(Required)</span></label>
<input type=”text” name=”name” id=”name” size=”30″ value=”” class=”text-input” />
</li>
<li>
<label for=”email” id=”label-email”>E-mail Address <span class=”error” id=”error-email”>(Required)</span></label>
<input type=”text” name=”email” id=”email” size=”30″ value=”” class=”text-input” />
</li>
<li>
<label for=”snailmail” id=”label-snailmail”>Mailing Address <span class=”optional”>(Optional)</span></label>
<input type=”text” name=”snailmail” id=”snailmail” size=”30″ value=”” class=”text-input” />
</li>
<li>
<label for=”message” id=”label-name”>Message <span class=”error” id=”error-message”>(Required)</span></label>
<textarea name=”message” id=”message” size=”30″ value=”” class=”text-input”></textarea>
</li>
<li>
<input type=”submit” name=”submit” id=”submit” value=”Send Message” />
</li>
</ul>
</form>
</div>
<!– –>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
>>>>>>>>>
contact-form.js<<<<<<<<<<<<<<
$( document ).ready( function() {
$( ‘#contact-form input[ id != “submit” ], #contact-form textarea’ ).each( function() {
$( this ).focus( function() {
$( this ).animate( { backgroundColor: ‘#f5f5f5’ }, 100 );
} );
$( this ).blur( function() {
$( this ).animate( { backgroundColor: ‘#fff’ }, 100 );
} );
} );
$( ‘.error’ ).hide();
$( ‘input[ id = “submit” ]’ ).click( function() {
$( ‘.error’ ).hide();
var hasError = false;
var targetElem;
var commentsVal = $( “textarea#message” ).val();
if( commentsVal == “” ) {
$( “#error-message” ).show();
targetElem = “textarea#message”;
hasError = true;
}
var emailVal = $( “input#email” ).val();
if( emailVal == “” ) {
$( “#error-email” ).show();
targetElem = “input#email”;
hasError = true;
}
var nameVal = $( “input#name” ).val();
if( nameVal == “” ) {
$( “#error-name” ).show();
targetElem = “input#name”;
hasError = true;
}
var snailVal = $( “input#snailmail” ).val();
if( hasError ) {
$( targetElem ).focus();
}
if( !hasError ) {
$( this ).fadeOut( 200 );
$( “input#name” ).attr( “disabled”, true );
$( “input#email” ).attr( “disabled”, true );
$( “input#snailmail” ).attr( “disabled”, true );
$( “textarea#message” ).attr( “disabled”, true );
//alert( “name: ” + nameVal + “, email: ” + emailVal + “, snail: ” + snailVal + “, comments: ” + commentsVal );
var subjectVal = “Message from ” + nameVal;
$.post( “send.php”,
{ name: nameVal, email: emailVal, snail: snailVal, comments: commentsVal, subject: subjectVal },
function( data ) {
/*
$( “#sendEmail”).slideUp(“normal”, function() {
$(“#sendEmail”).before(‘<h1>Success</h1><p>Your email was sent.</p>’);
});
/*
$( ‘#contact_form’ ).html( “<div id=’message’></div>” );
$( ‘#message’ ).html( “<h4>Contact Form Submitted!</h4>” )
.append( “<p>We will be in touch soon.</p>” )
.hide()
.fadeIn( 1500 );
$( ‘#contact-form form’ ).slideUp( “normal”, function() {
$( ‘#contact-form’ ).html( “<h4 class=’extra’>Contact Form Submitted!</h4><p>We will be in touch soon.</p>” )
.hide()
.fadeIn( 200 );
} );
//alert( “done” );
}
);
}
return false;
} );
} );
>>>>>>>>>>>>
send.php<<<<<<<<<<<<(I think something is wrong in this file)
<?php
$to = “
$subject = “Message from mysite.com”;
$email = $_REQUEST[’email’] ;
$message = $
$headers = “From: $email”;
$sent = mail($to, $subject, $message, $headers) ;
?>