Support » Plugin: Contact Form 7 » Undefined index: HTTP_X_REQUESTED_WITH in contact-form-7\includes\controller.php

  • On line 86 of controller.php, you have if ( $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) which triggers a NOTICE level error because it isn’t set even though it is making an AJAX request.
    A simple fix would be simply to test if( isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ), but that just does away with the NOTICE error message and doesn’t fix the problem.

    I am curious why you aren’t submitting the form to wp-admin/admin-ajax.php as described in and then adding the appropriate ajax functions to catch the request. When done correctly, it adds additional security measures.

    Since I have benefited from the use of CF7, I would gladly contribute and help implement this if you’re interested and if there’s not a particular reason you avoided this route.

    Thanks again for your hard work!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Takayuki Miyoshi


    Thanks for reporting this. I have tried admin-ajax.php before, but I realized that file uploading part is difficult to be implemented on that. If you have good idea, please let me know.

    Thanks for the quick response! I haven’t tried file submissions with forms in this way, but I’ll definitely spend a little time testing to see if I can figure something out. It seems like it should be possible though…

    I’m working on a much lighter DB plugin for CF7 than the one currently available because CF7 is the best form plugin available, just lacking the database part, therefore if I can contribute anything to making it better, I’d be glad to do so.
    I’ll keep you updated on what I discover….

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Undefined index: HTTP_X_REQUESTED_WITH in contact-form-7\includes\controller.php’ is closed to new replies.