Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/impacts.to.git
<?php
// Configuration
$yourEmail = 'curious@impacts.to';
$yourWebsite = "Impacts";
$thanksPage = 'preorder.html';
$subject = 'Impacts: Pre-order';

// Main Code
function clean( $data ) {
  return trim( stripslashes( strip_tags( $data ) ) );
}

// Build up the message from the form's input values.
$message = "";

// Make sure the request method is an HTTP POST call.
if( strcasecmp( $_SERVER[ 'REQUEST_METHOD' ], 'POST' ) == 0 ) {
  foreach( $_POST as $key => $val ) {
    if( ! is_array( $val ) ) {
      $values = array();
      $values[ $key ] = $val;
      $val = $values;
    }

    foreach( $val as $subval ) {
      if( ! empty( $subval ) ) {
        $message .= ucwords( $key ) . ': ' . clean( $subval ) . PHP_EOL;
      }
    }
  }

  $message .= PHP_EOL;
  $message .= 'IP: '.$_SERVER[ 'REMOTE_ADDR' ] . PHP_EOL;
  $message .= 'Browser: '.$_SERVER[ 'HTTP_USER_AGENT' ] . PHP_EOL;

  if( strstr( $_SERVER[ 'SERVER_SOFTWARE' ], 'Win' ) ) {
    $headers = "From: $yourEmail" . PHP_EOL;
  } else {
    $headers = "From: $yourWebsite <$yourEmail>" . PHP_EOL;  
  }

  $headers .= "Reply-To: {$_POST['email']}" . PHP_EOL;

  mail( $yourEmail, $subject, $message, $headers );
}

header( "Location: $thanksPage" );
?>