2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
15 $_user_location = 'public';
17 define('AT_INCLUDE_PATH', '../include/');
18 require(AT_INCLUDE_PATH.'vitals.inc.php');
20 if (isset($_POST['cancel'])) {
21 $msg->addFeedback('CANCELLED');
22 header('Location: index.php');
26 $onload = 'document.form.from.focus();';
27 require(AT_INCLUDE_PATH.'header.inc.php');
29 if ($_SESSION['member_id']) {
30 $sql = "SELECT first_name, last_name, email FROM ".TABLE_PREFIX."members WHERE member_id=$_SESSION[member_id]";
31 $result = mysql_query($sql, $db);
32 if ($row = mysql_fetch_array($result)) {
33 $student_name = AT_print($row['last_name'], 'members.last_name');
34 $student_name .= (AT_print($row['first_name'], 'members.first_name') ? ', '.AT_print($row['first_name'], 'members.first_name') : '');
36 $student_email = AT_print($row['email'], 'members.email');
40 if (!$_config['contact_email']) {
41 $msg->printErrors('CONTACT_INFO_NOT_FOUND');
42 require(AT_INCLUDE_PATH.'footer.inc.php');
46 if (isset($_POST['submit'])) {
47 $missing_fields = array();
49 $_POST['subject'] = trim($_POST['subject']);
50 $_POST['body'] = trim($_POST['body']);
52 if ($_POST['from'] == '') {
53 $missing_fields[] = _AT('from_name');
56 if ($_POST['from_email'] == '') {
57 $missing_fields[] = _AT('from_email');
58 } else if (!preg_match("/^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,6}$/i", $_POST['from_email'])) {
59 $msg->addError('EMAIL_INVALID');
62 if ($_POST['subject'] == '') {
63 $missing_fields[] = _AT('subject');
66 if ($_POST['body'] == '') {
67 $missing_fields[] = _AT('body');
70 if ($missing_fields) {
71 $missing_fields = implode(', ', $missing_fields);
72 $msg->addError(array('EMPTY_FIELDS', $missing_fields));
75 if (!$msg->containsErrors()) {
77 require(AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php');
79 $mail = new ATutorMailer;
81 $mail->From = $_POST['from_email'];
82 $mail->FromName = $stripslashes($_POST['from']);
83 $mail->AddAddress($_config['contact_email']);
84 $mail->Subject = $stripslashes($_POST['subject']);
85 $mail->Body = $stripslashes($_POST['body']);
88 $msg->printErrors('SENDING_ERROR');
93 $msg->printFeedbacks('ACTION_COMPLETED_SUCCESSFULLY');
94 require(AT_INCLUDE_PATH.'footer.inc.php');
101 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">
102 <div class="input-form">
104 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="from"><?php echo _AT('from_name'); ?></label><br />
105 <input type="text" name="from" id="from" size="40" value="<?php echo htmlspecialchars($stripslashes($_POST['from'])); ?>" />
109 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="from_email"><?php echo _AT('from_email'); ?></label><br />
110 <input type="text" name="from_email" id="from_email" size="40" value="<?php echo htmlspecialchars($stripslashes($_POST['from_email'])); ?>" />
114 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="subject"><?php echo _AT('subject'); ?></label><br />
115 <input type="text" name="subject" id="subject" size="40" value="<?php echo htmlspecialchars($stripslashes($_POST['subject'])); ?>" />
119 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="body_text"><?php echo _AT('body'); ?></label><br />
120 <textarea cols="55" rows="15" id="body_text" name="body"><?php echo htmlspecialchars($stripslashes($_POST['body'])); ?></textarea>
123 <div class="row buttons">
124 <input type="submit" name="submit" value="<?php echo _AT('send'); ?>" accesskey="s" />
125 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
130 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>