I have entered a form element into the page contents editor in wordpress.

form action="/home4/stevekeo/public_html/wp-includes/testforms.php" method="post"> ...

I want to use the selected value, and have created a php script in the /home4/stevekeo/public_html/wp-includes folder to access the user choice.

  $team = $_POST['teamname'];
  echo "Team selected was ". $team. ".<br />";

As I understand it, the PHP script named in the 'action' part of the form element is executed when the submit button is clicked. This doesn't appear to happen. Any help would be great, as I'm a relative WP/PHP novice. sorry - first attempt was mangled

2 Answers 2


You are right the action part is the directory to the execution script file. You can not use the static directory path like that, it should be used with get_home_path(); like

$path = get_home_path();
then action = '<?php echo $path."wp-includes/tests-form.php" ?>';

More: https://codex.wordpress.org/Function_Reference/get_home_path


Rather that entering form element into the page contents editor in wordpress, make a separate template and load it through "Page Attribute".

Then in form action, place below:

action="<?php echo home_url('/page-name'); ?>"

Let me know if any problems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.