Jump to content


[ger - Germany] : Contactme


  • You cannot reply to this topic
No replies to this topic

#1 Helicopter

    Etomite Forum Newbie

  • Member
  • 15 posts

Posted 06 August 2005 - 06:58 PM

/* ContactMe 0.1 snippet for Etomite by Vassili Slessarenko    */
/* This snippet generates a very simple form, which can be used for contact purposes within a website.
   It first outputs the form, then it checks the e-mail address that the sender has given and then 
   returns a "message-has-been-sent" message.
   Do make sure the page is non-Cacheable!        */

/* Configuration Section (Feel free to change these as needed). */

## This is probably the most important part of the script... It contains the address to which the e-mails will be
## so make sure the address is correct.

$address_to = 'empfaenger@yyyy.de';

## These 3 change what is at first displayed in the form fields (once clicked on these disappear):

$initial_name_string = 'Bitte Namen eingeben';
$initial_email_string = 'beispiel@domain.tip';
$initial_subject_string = 'Bitte Betreff eingeben';

## These will determine the size of the fields and should be pretty self-explanatory.

$name_width = '80';
$email_width = '80';
$subject_width = '80';
$text_cols = '60';
$text_rows = '20';

# $subject_prepend variable can be used to supply a string which will always come before the user written subject.
# This means you can filter the e-mails by subject and put them into a separate folder.

$subject_prepend = '{Heliseiten} ';

## $email_sent_msg - This sets the message that the sender sees when the e-mail has been successfully sent. 

$email_sent_msg = '<h2>Danke für Deine E-Mail!</h2>'."\n";
$email_sent_msg .= "<p>Die Mail wurde verschickt. Ich werde so bald als möglich Antworten.</p>"."\n";


/* ------------------------------------------------------*/
/* Don't mess with this unless you know what ur doing!!! */
/* This is the actual code...                            */
/* ------------------------------------------------------*/


  $mail_form = '';
                $mail_form .= '<form action="" method="post" id="contact_me">'." \n ";
  $mail_form .= '<p><label for="name">Dein Name:<br />'." \n ";
  $mail_form .= '<input type="text" name="name" id="name"';
  


  if (isset($_POST['name'])) { 
  	$mail_form .= " value=\"".$_POST['name']."\""; 
  } 
  else { 
  	$mail_form .= ' value="'.$initial_name_string.'"'; 
  } 
  
  if (!isset($_POST['name'])) { 
  	$mail_form .= " onclick=\"document.forms[0].name.value=''\" "; 
  }

                $mail_form .= 'size="'.$name_width.'" /></label></p>'." \n";
  $mail_form .= '<p><label for="email">Deine E-Mail:<br />'." \n";
  $mail_form .= '<input type="text" name="email" id="email" ';

  if (isset($_POST['email'])) { 
  	$mail_form .= "value=\"".$_POST['email']."\" "; 
  } else { 
  	$mail_form .= 'value="'.$initial_email_string.'" '; 
  } 
  if (!isset($_POST['email'])) { 
  	$mail_form .= "onclick=\"document.forms[0].email.value=''\" "; 
  }

  $mail_form .= 'size="'.$email_width.'" /></label></p>'."\n";
  $mail_form .= '<p><label for="subject">Betreff:<br />'."\n";
  $mail_form .= '<input type="text" name="subject" id="subject" ';
  
  if (isset($_POST['subject'])) {
  	$mail_form .= "value=\"".$_POST['subject']."\" "; 
  } else {
  	$mail_form .= 'value="'.$initial_subject_string.'" '; 
  }
  
  if (!isset($_POST['subject'])) { 
  	$mail_form .= "onclick=\"document.forms[0].subject.value=''\" "; 
  } 
  $mail_form .= 'size="'.$subject_width.'" /></label></p>'."\n";
  $mail_form .= '<p><label for="content_text">Text:<br />'."\n";
  $mail_form .= '<textarea name="content_text" id="content_text" rows="'.$text_rows.'" cols="'.$text_cols.'">';
  
  if (isset ($_POST['content_text'])) { 
  	$mail_form .= $_POST['content_text']; 
  }
  $mail_form .= '</textarea></label></p>'."\n";
  $mail_form .= '<p><input type="hidden" name="send_email" value="sent" />'."\n";
  $mail_form .= '<input type="submit" value="Mail senden" /><input type="reset" value="Reset" /></p>'."\n";
  $mail_form .= '</form>'."\n";
  $mail_form .= '<p>Bitte nur 1 mal auf Senden klicken!</p>'."\n";


if (isset($_POST['send_email']) && $_POST['send_email'] == 'sent') {
	
/* check e-mail variable, output errors, then send the e-mail + thank you message */

	
  /* take a given email address and split it into the  
  username and domain. */
	
  list($userName, $mailDomain) = split("@", $_POST['email']);
  if (checkdnsrr($mailDomain, "MX")) {

   // this is a valid email domain! -> send the mail and say thanks!
    
    $name = $_POST['name'];
    $email = $_POST['email'];
    $subject = "$subject_prepend".$_POST['subject'];
    $content_text = $_POST['content_text'];
    $message = stripslashes($content_text);
    
    $headers = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text; charset=iso-8859-1\r\n";
  	$headers .= "From: $name <$email>\r\n";

  	$headers .= "X-Priority: 1\r\n";
  	$headers .= "X-Mailer: Etomite PHP mailer\r\n";
  	
  	mail ($address_to, $subject, $message, $headers);
  	
  	$output = '';
  	$output .= $email_sent_msg;
  	return $output;
  	
  
  } else {
  	/* return an error and add the form */
    $output = '';
  	$output .= '<p class="error">Bitte eine gültige Mailadresse zur Rückantwort eingeben.</p>';
                        $output .= $mail_form;
  	return $output;
  }
	
} else {
	/* return an html e-mail form */
	$output = '';
        $output .= $mail_form;
	return $output;
}

Edited by Helicopter, 06 August 2005 - 07:00 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users