Why Isn’t My PHP Form Submitting Properly in WordPress?

0
4
Asked By CreativeNomad123 On

I'm having trouble getting my PHP form to work on a local WordPress site hosted with WPEngine. I'm using the CSS & Javascript ToolBox and have my script in the header. Despite trying various methods including POST, GET, and REQUEST, I'm unable to pass the form input to PHP. The only response I get is 'not registered'. I've experimented with different PHP code approaches, including sending the script name and using variables like `$_SERVER['SCRIPT_FILENAME']`, but nothing seems to work. In addition, my CSS styles are getting overridden, and I have an `onclick()` function in my Javascript for the submit button. Any tips would be appreciated! Here's a snippet of my form code: [form code] and my PHP code: [PHP code].

2 Answers

Answered By TechWhizKid99 On

It sounds like your main issue is that the CSS & JS Toolbox is just injecting your PHP code as plain text instead of executing it. To properly handle forms in WordPress, you should use `admin-ajax.php` with `wp_ajax_` hooks, or better yet, include your PHP processing logic in a template that WordPress can execute as PHP. Also, I noticed you have a space in `<? php`, which will cause issues in standard PHP setups. If you find the WordPress hooks too confusing, consider hiring a developer from services like Codeable who specializes in custom WordPress forms.

Answered By CuriousCoder99 On

From what you've mentioned, the hosting environment might be causing troubles too. WPEngine, like many managed WordPress hosts, has restrictions on running custom scripts, which might be blocking your requests. Double-check their list of disallowed plugins and functions—it could be affecting your setup.

CreativeNomad123 -

That makes sense! I'll look into their documentation on this. Thanks!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.