0

I'm new to web page development and to code. I have this HTML code in Wordpress Text editor:

    <form action="process.php" method="post">
        Name: <input type="text" name="user_name"/>
        Last Name: <input  type="text" name="user_last_name"/>
        <input  type="submit" value="submit"/>

My question is: Where exactly do I need to put the "process.php" file on wordpress so it will process the data of the form? Or if I totally have the wrong picture here. Thanks in advance. And sorry for my english.

1

Have you try with admin-post.php for your form submission. admin_post hook available in WordPress gives you great control over the flow of execution for your form.

Using the above form, the following HTML content would execute the above hook when the user clicks either Submit.

<form action="http://www.example.com/wp-admin/admin-post.php" method="post">
  <input type="hidden" name="action" value="custom_form">
  <input type="hidden" name="data" value="formid">
    Name: <input type="text" name="user_name"/>
    Last Name: <input  type="text" name="user_last_name"/>
  <input type="submit" value="Submit">
</form>

Then, create a request or form handler for an "custom_form" action request, you would create a hook like this either in our theme function or plugin file.

add_action( 'admin_post_custom_form', 'my_custom_form_handler' );

function my_custm_form_handler() {
    // Handle request and process the form
}

For more info visit

Note: you can also use nonce & sanitize form field for more secure & validation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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