Update Two: After doing some testing, I found that it does not work when jQuery is loaded in the page. My page relies on jQuery, so what should I do?
Update: You can see the problematic page here here, and the working test page here.
I'm making a contact form, and it looks like this
<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="../sendemail.php">
<div class="row-fluid">
<div class="span5">
<label>First Name</label>
<input name="first" type="text" class="input-block-level" required="required" placeholder="Your First Name">
<label>Last Name</label>
<input name="last" type="text" class="input-block-level" required="required" placeholder="Your Last Name">
<label>Email Address</label>
<input name="email" type="text" class="input-block-level" required="required" placeholder="Your email address">
</div>
<div class="span7">
<label>Message</label>
<textarea name="message" id="message" required class="input-block-level" rows="8"></textarea>
</div>
</div>
<button type="submit" class="btn btn-primary btn-large pull-right">Send Message</button>
<p> </p>
</form>
Nothing too fancy. sendemail.php looks like this
<?php
header('Content-type: application/json');
$status = array(
'type'=>'success',
'message'=>'Email sent!'
);
$name = @trim(stripslashes($_POST['first']." ".$_POST['last']));
$email = @trim(stripslashes($_POST['email']));
$subject = "Monarc - Message From ".$name;
$message = @trim(stripslashes($_POST['message']));
$email_from = $email;
$email_to = 'xxx@xxx.xxx';
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;
$success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
echo json_encode($status);
die;
The email comes through, but the postdata isn't coming through in the email. It says (unknown sender) as the sender, and the body looks like this:
Name:
Email:
Subject: Monarc - Message From
Message:
What am I doing wrong?
Thanks!