Location: PHPKode > projects > ProjectPress > projectpress/pm_contact.php
<?php
/**
 * ProjectPress contact form
 *
 * @package ProjectPress
 * @since 2.0
 */

// Starts the session.
session_start();

define('access',true);

include(dirname(__FILE__) . '/config.inc.php');
include(PM_DIR . 'pm-includes/global.inc.php');
require(PM_DIR . 'pm-includes/functions.php');
include(PM_DIR . 'pm-includes/header.php');

// Checks if user is logged in; if not redirect to login page.
if($current_user->hasPermission('access_site') != true) { pm_redirect(PM_URI . '/index.php'); }

// Enable for error checking and troubleshooting.
# display_errors();

if($_POST) {
$subject = pmdb::connect()->escape($_POST['subject']);
$email = pmdb::connect()->escape($_POST['email']);
$message = pmdb::connect()->escape($_POST['message']);

$to = get_pm_option('admin_email');
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; UTF-8' . "\r\n";
$headers .= 'From: ' . $user->get_name($_SESSION['username']) . ' <' . $user->get_user_info($_SESSION['username'],'email') . '>' . "\r\n";
$body = "From: " . $user->get_name($_SESSION['username']) . "\r\n E-Mail: " . $user->get_user_info($_SESSION['username'],'email') . "\r\n Message:\r\n " . $message;

pm_mail($to, $subject, $body, $headers);
}
?>

<script type="text/javascript">
$(function() {
$(".cf-submit").click(function() {
var first_name = $("#first_name").val();
var last_name = $("#last_name").val();
var subject = $("#subject").val();
var email = $("#email").val();
var message = $("#message").val();
var dataString = 'first_name=' + first_name + '&last_name=' + last_name + '&subject=' + subject + '&email=' + email + '&message=' + message;

if(first_name=='' || last_name=='' || subject=='' || email=='' || message=='')
{
$('.success').fadeOut(200).hide();
$('.error').show();
$('.error').fadeOut(5000);
}
else
{
$.ajax({
type: "POST",
url: "contact.php",
data: dataString,
success: function(){
$('.success').show();
$('.success').fadeOut(2000);
$('.error').fadeOut(200).hide();
$('#subject').val('');
$('#email').val('');
$('#message').val('');
}
});
}
return false;
});
});
</script>

				<div id="page-title">
					<img src="<?php echo PM_URI ?>/images/mail.png" alt="" /><h1>Contact</h1>
				</div>
				
				<div class="success" style="display:none">Your message has been sent and someone will contact you as soon as possible.</div>
				<div class="error" style="display:none">Sorry, all fields must be filled in before you can submit the form.</div>

				<div id="middle">
				<p>Are you having issues with ProjectPress or you think you may have found a bug? Please contact us by using the form below.</p>
					<form name="form" action="" method="post">
					<table cellpadding="0" cellspacing="2" align="center" width="100%">
					<tbody>

						<tr>
							<th>First Name:</th>
							<td><input readonly class="forminput" id="first_name" name="first_name" value="<?php _e($user->get_user_info($_SESSION['username'],'first_name')); ?>" /></td>
						</tr>
						
						<tr>
							<th>Last Name:</th>
							<td><input readonly class="forminput" id="last_name" name="last_name" value="<?php _e($user->get_user_info($_SESSION['username'],'last_name')); ?>" /></td>
						</tr>
						
						<tr>
							<th>Subject:</th>
							<td><input class="forminput" id="subject" name="subject" type="text" size="30" /></td>
						</tr>
						
						<tr>
							<th>Email:</th>
							<td><input class="forminput" id="email" name="email" type="text" size="30" /></td>
						</tr>
						
						<tr>
							<th>Message:</th>
							<td><textarea class="forminput" id="message" name="message" size="30" /></textarea></td>
						</tr>
						
						<tr>
							<td></td>
							<td colspan="2"><input type="submit" value="Submit" name="submit" class="cf-submit" id="sub_button" /></td>
						</tr>

					</tbody>
	 				</table>
</form>
</div>


<?php
include(PM_DIR . 'pm-includes/footer.php');
Return current item: ProjectPress