Contact Form 7
Undefined index: HTTP_X_REQUESTED_WITH in contact-form-7\includes\controller.php (3 posts)

  1. amereservant
    Posted 4 years ago #

    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 http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/#js-global 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!


  2. Takayuki Miyoshi
    Plugin Author

    Posted 4 years ago #

    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.

  3. amereservant
    Posted 4 years ago #

    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....

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Contact Form 7
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic