· 8 years ago · May 10, 2018, 02:34 PM
1<?php
2$field_fname = $_POST['c_firstname'];
3$field_lname = $_POST['c_lastname'];
4$field_email = $_POST['c_email'];
5$field_type = $_POST['c_type'];
6$field_adname = $_POST['a_name'];
7$field_comment = $_POST['c_comment'];
8
9 if(!$field_fname || !$field_lname || !$field_email || !$field_type || !$field_adname || !$field_comment)
10 {
11 //error message
12 }else{
13
14
15$mail_to = '*****@gmail.com';
16/*Subject Identifier*/
17if($field_type == "Advertisement")
18 {
19 $subject = 'Ad submitted for : '.$field_adname;
20 }
21else
22 if ($field_type == "Server Advertisment")
23 {
24 $subject = 'Server submitted for an ad: ' .$field_adname;
25 }
26else {$subject = 'User submitted a comment';}
27 //End Subject Identifier
28
29$body_message = 'Submitter Name: '.$field_fname." ".$field_lname."\n";
30$body_message .= 'Submitter email: '.$field_email."\n";
31$body_message .= 'Reason for contact: '.$field_type."\n";
32$body_message .= 'Name of advertiser/ment: '.$field_adname."\n";
33$body_message .= 'Message: '."\n".$field_comment."\n";
34
35$header = 'From:' .$field_email;
36
37$mail_status = mail($mail_to, $subject, $body_message, $header);
38
39if(empty($field_fname) || empty($field_lname) || empty($field_email)) { ?>
40 <script language="javascript" type="text/javascript">
41 alert('Submition failed. Please make sure you have filled out all categories. If you did this, and see this message, send an email to *****@gmail.com. You will now be redirected to the contact page.');
42 window.location = '../contactus.php';
43 </script>
44<?php
45 } else if ($mail_status)
46 { ?>
47 <script language="javascript" type="text/javascript">
48 alert('Thank you for submitting your ad or comment. We will get back to you shortly. You will now be taken back to the home page.');
49 window.location = '../realindex.php';
50 </script>
51<?php }} ?>