wp/wp-content/themes/IN-MOTION-package-u1/in-motion/scripts/contact-form.php
author ymh <ymh.work@gmail.com>
Mon, 08 Sep 2025 19:44:41 +0200
changeset 23 417f20492bf7
parent 0 d970ebf37754
permissions -rwxr-xr-x
Update Docker configuration and plugin versions - Upgrade MariaDB from 10.6 to 11 with auto-upgrade support - Add WordPress debug environment variable to FPM container - Update PHP-FPM Dockerfile base image - Update Include Mastodon Feed plugin with bug fixes and improvements - Update Portfolio plugin (v2.58) with latest translations and demo data enhancements - Remove old README.md from Mastodon Feed plugin 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
//If the form is submitted
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
if(isset($_POST['submitted'])) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
	
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
	// require a name from user
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
	if(trim($_POST['contactName']) == '') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
		$nameError =  'Forgot your name!'; 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
		$hasError = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
		$name = trim($_POST['contactName']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
	
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
	// need valid email
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
	if(trim($_POST['email']) == '')  {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
		$emailError = 'Forgot to enter in your e-mail address.';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
		$hasError = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
	} else if (!preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", trim($_POST['email']))) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
		$emailError = 'You entered an invalid email address.';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
		$hasError = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
		$email = trim($_POST['email']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
		
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
	// we need at least some content
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
	if(trim($_POST['comments']) == '') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
		$commentError = 'You forgot to enter a message!';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
		$hasError = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
		if(function_exists('stripslashes')) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
			$comments = stripslashes(trim($_POST['comments']));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
			$comments = trim($_POST['comments']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
		
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
	// upon no failure errors let's email now!
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
	if(!isset($hasError)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
		
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
		$emailTo=''; 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
		if ( function_exists( 'get_option_tree') ){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
					if( get_option_tree( 'contact_page_email') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
						$emailTo = get_option_tree( 'contact_page_email' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
						
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
		$body = "Name: $name \n\nEmail: $email \n\nComments: $comments";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
		$headers = 'From: ' .' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
		mail($emailTo, $headers, $body);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
		$emailSent = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
?>