Title: PHP warning &#8220;SERVER_NAME&#8221;
Last modified: February 22, 2024

---

# PHP warning “SERVER_NAME”

 *  Resolved [skhl](https://wordpress.org/support/users/skhl/)
 * (@skhl)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/php-warning-server_name/)
 * Hi, I keep getting this PHP warning in my PHP error log related to this plugin,
   I’m not sure if this is something you fix or do I need to contact my web host?
   Thank you
 * PHP Warning: Undefined array key “SERVER_NAME” in /home/mydomain/public_html/
   wp-content/plugins/very-simple-contact-form/vscf.php on line 139

Viewing 13 replies - 1 through 13 (of 13 total)

 *  Plugin Author [Guido](https://wordpress.org/support/users/guido07111975/)
 * (@guido07111975)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/php-warning-server_name/#post-17446490)
 * Hi,
 * This is being used for creating the sum transient. Your form works as expected,
   no issues with sum or form submission?
 * Guido
 *  Plugin Author [Guido](https://wordpress.org/support/users/guido07111975/)
 * (@guido07111975)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/php-warning-server_name/#post-17447162)
 * Hi again,
 * Normally `$_SERVER['SERVER_NAME']` returns your domain. I’ve read that the `$
   _SERVER` superglobal doesn’t work when using WP-CLI. Are you using that perhaps?
 * if not, it may then be a conflict with another plugin. Could you please deactivate
   other plugins and check if new warnings are added to your log?
 * Guido
 *  Thread Starter [skhl](https://wordpress.org/support/users/skhl/)
 * (@skhl)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/php-warning-server_name/#post-17448486)
 * Hi Guido, thanks for your reply. There are no issues with the sum or form submission
   and I’m not using WP-CLI. In that case, may have to try deactivating plugins 
   to see if there’s a conflict.
 *  Plugin Author [Guido](https://wordpress.org/support/users/guido07111975/)
 * (@guido07111975)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/php-warning-server_name/#post-17448805)
 * Hi,
 * If you could do a test with deactivating your other plugins, please do.
 * Guido
 *  [belettebuck](https://wordpress.org/support/users/belettebuck/)
 * (@belettebuck)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/php-warning-server_name/#post-17523064)
 * Hello, I also have the problem.
 * Here is a solution (not the best):
 *     ```wp-block-code
       /***/wp-content/plugins/very-simple-contact-form # diff vscf.php vscf_fix.php 
       140c140,144
       <       $server = preg_replace("/[^a-zA-Z0-9]/", "", $_SERVER['SERVER_NAME']);
       ---
       >       if (isset($_SERVER["SERVER_NAME"])) {
       >               $server = preg_replace("/[^a-zA-Z0-9]/", "", $_SERVER['SERVER_NAME']);
       >       } else {
       >               $server = 'CRONTAB';
       >       }
       ```
   
 * The variable ‘$_SERVER[“SERVER_NAME”]’ is not defined when running the WordPress
   crontab (wp-cron.php).
 * The email I received from crontab (every 15min): PHP Warning: Undefined array
   key “SERVER_NAME” in /***/wp-content/plugins/very-simple-contact-form/vscf.php
   on line 140
 *  Plugin Author [Guido](https://wordpress.org/support/users/guido07111975/)
 * (@guido07111975)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/php-warning-server_name/#post-17526340)
 * Hi,
 * Thanks, will add the extra check in next version.
 * Is the redirect working when you submit form (is the “thank you” message displayed)?
   
   Because the redirect also uses the `$_SERVER` global.
 * Guido
 *  [belettebuck](https://wordpress.org/support/users/belettebuck/)
 * (@belettebuck)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/php-warning-server_name/#post-17526914)
 * Hello,
 * I don’t really know what to look for, could you say more?
 * The form works well (reception for the client and the site manager)
 *  Plugin Author [Guido](https://wordpress.org/support/users/guido07111975/)
 * (@guido07111975)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/php-warning-server_name/#post-17527061)
 * Hi,
 * I’m trying to duplicate “your” behavior so I fully understand the problem. For
   what are you using the cron job?
 * If you press submit and submission is successful the thank you message is displayed.
   And if you look in the address bar of your browser this should be added to the
   URL of your contact page: `vscf-sh=success`
   But I’m pretty certain this works
   as expected.
 * Guido
 *  [belettebuck](https://wordpress.org/support/users/belettebuck/)
 * (@belettebuck)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/php-warning-server_name/#post-17527392)
 * Cron is used to periodically perform tasks on WordPress, e.g.: update plugins,
   email campaign, etc.
 * Here is an example of a cron task that I have: `php /bin/su --shell /bin/sh --
   command "/usr/bin/php /var/www/[VHOST]/docs/wp-cron.php" [USER_PHP_FPM]`
 * I confirm, the `vscf-sh=success` is present.
 * I thank you for your energy 😉
 *  Plugin Author [Guido](https://wordpress.org/support/users/guido07111975/)
 * (@guido07111975)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/php-warning-server_name/#post-17528195)
 * Hi,
 * I know what they are but have no experience with using them and unfortunately
   not able to reproduce this on my test installs. But a simple check for SERVER_NAME
   will fix this. Will update plugin this week.
 * Guido
 *  [belettebuck](https://wordpress.org/support/users/belettebuck/)
 * (@belettebuck)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/php-warning-server_name/#post-17529082)
 * Thank you 😉 🙂
 *  Plugin Author [Guido](https://wordpress.org/support/users/guido07111975/)
 * (@guido07111975)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/php-warning-server_name/#post-17536264)
 * Hi [@skhl](https://wordpress.org/support/users/skhl/) and [@belettebuck](https://wordpress.org/support/users/belettebuck/)
 * I have just updated plugin and this issue should be fixed now.
   Please do a test
   form submission and let me know if it still works as expected. It should 😉
 * Guido
 *  [belettebuck](https://wordpress.org/support/users/belettebuck/)
 * (@belettebuck)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/php-warning-server_name/#post-17537275)
 * Hello Guido
 * Yes it works for me!
 * I thank you 😉

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘PHP warning “SERVER_NAME”’ is closed to new replies.

 * ![](https://ps.w.org/very-simple-contact-form/assets/icon-256x256.png?rev=1415751)
 * [VS Contact Form](https://wordpress.org/plugins/very-simple-contact-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/very-simple-contact-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/very-simple-contact-form/)
 * [Active Topics](https://wordpress.org/support/plugin/very-simple-contact-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/very-simple-contact-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/very-simple-contact-form/reviews/)

 * 13 replies
 * 3 participants
 * Last reply from: [belettebuck](https://wordpress.org/support/users/belettebuck/)
 * Last activity: [2 years, 2 months ago](https://wordpress.org/support/topic/php-warning-server_name/#post-17537275)
 * Status: resolved