How to capture client IP address in Php email form using $_SERVER[REMOTE_ADDR’]

Here’s a simple way of capturing IP Addresses from an Email Form:
1. You should have a working email form already.
2. Use this code/variable in your ‘post’ send.php file. This is the second file to execute your form.
$ip = $_SERVER[‘REMOTE_ADDR’]
3. To echo this in your email, use:
IP: $ip \n

——————

Example:

<?php
$mailto = ‘myemail@gmail.com’ ;

$name = $_REQUEST[‘name’] ;
$email = $_REQUEST[’email’] ;
$phone = $_REQUEST[‘phone’] ;
$message = $_REQUEST[‘message’] ;
$ip = $_SERVER[‘REMOTE_ADDR’] ;

$subject = “FROM SITE CONTACT FORM” ;

$message=”
Name: $name \n
Email: $email \n
Phone: $phone \n
Message: $message \n
IP: $ip \n
“;

$from=”From: $name\r\n”;

mail($mailto, $subject, $message, $from);
header( “Location:thanks.html” );
?>

————-

Good Luck.

How To Remove Billing Address / Billing Details on Woocommerce Checkout

In case you want to get rid of the Billing Address requirement during woocommerce checkout.

I do this directly to the woocommerce file via FTP:

Locate the woocommerce “class-wc-countries.php” file by going to:
wp-content > plugins > woocommerce > includes > class-wc-countries.php

Edit this file and add the following at the very end.
——————————————————————————————————–

add_filter( ‘woocommerce_checkout_fields’ , ‘custom_override_checkout_fields’ );

function custom_override_checkout_fields( $fields ) {
unset($fields[‘billing’][‘billing_first_name’]);
unset($fields[‘billing’][‘billing_last_name’]);
unset($fields[‘billing’][‘billing_company’]);
unset($fields[‘billing’][‘billing_address_1’]);
unset($fields[‘billing’][‘billing_address_2’]);
unset($fields[‘billing’][‘billing_city’]);
unset($fields[‘billing’][‘billing_postcode’]);
unset($fields[‘billing’][‘billing_country’]);
unset($fields[‘billing’][‘billing_state’]);
unset($fields[‘billing’][‘billing_phone’]);
unset($fields[‘order’][‘order_comments’]);
unset($fields[‘billing’][‘billing_address_2’]);
unset($fields[‘billing’][‘billing_postcode’]);
unset($fields[‘billing’][‘billing_company’]);
unset($fields[‘billing’][‘billing_last_name’]);
unset($fields[‘billing’][‘billing_email’]);
unset($fields[‘billing’][‘billing_city’]);
return $fields;
}

————————————————————–

 

 

Phpmyadmin you probably tried to upload too large file

How to increase file size limit of Phpmyadmin in Xampp / localhost

If you get this error when uploading a large database file. Do the following:
1. Go to your xampp directory C:\xampp\php\_php.ini
2. Rename _php.ini to php.ini and save a backup copy.
3. Open php.ini using a text editor, notepad etc…
4. Search for the following and change their values:

upload_max_filesize = 128M
post_max_size = 128M
max_execution_time = 300
max_input_time = 60

5. After changing their values, restart xampp.

How to align center an inline-block element

Here’s a quick trick to center an inline-block element. When you normally do this, for example creating a CSS BUTTON and you want it centered, it would automatically float to the left. To fix this, you just need to add a width and a margin of “0 auto”. However, it won’t be fluid when resizing your browser.

A simple trick is to wrap it inside another div and add ‘text-align:center’

Example:
CSS:

.btn2{
display:inline-block;
background: red;
}

HTML:

<div style=”text-align: center;”>
<div class=”btn2b”>Order Now!</div>
</div>