One way to accomplish this is to setup two pages, with two page templates, one with your form code and the other with your mail code. The form action would point to the permalink of the page whose template hosts the mail code.
That said, I’d actually recommend using a plugin like Contact Form 7 instead. It’s highly modular and customizable and is a major time saver.
Related Posts:
- Get Admin Email Address From External PHP page
- Contact form won’t submit
- PHP- Why is my contact form keep showing it is invalid? [closed]
- Contact form – problem with displaying message about sent mail
- custom contact form no longer working (because of 3.2?)
- How to put a form with php code into a variable or shortcode?
- Can a page contain php code?
- How to send form data from WordPress (Meta Box) to an OData service?
- What is the alternative code to if (isset ($_POST) && !empty ($_POST) to avoid warnings?
- WordPress shortcode returns the data before
- Shortcode to embed Edit Account form not working
- Form Submission Not Working In Custom Theme
- Capture form data in one function and use it in another function (same file)
- How to display success message correctly and delete it when the page is refreshed
- Using admin-post.php for admin form but it directs me to admin-post.php white screen
- Why does my user not get added to the database on custom registration?
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- How to add post meta in while loop?
- How to set cookies
- PHP Contact form
- Get wp_current_user_id using PHP and MySQL
- Adding Additional Variables on Menus Page
- form built dynamically with php, not submitting
- Simple php in wordpress widget [closed]
- Search only working on front page (index) , not working on other pages
- form $_post action value gets truncated after it passes through two forms
- Pass important values server-side when processing form
- WPDB secure custom form
- Adding attribute to the post.php form tag in wp-admin
- How to make blog post entries appear as input form instead of just text?
- Adding data to custom wordpress database table
- Make a page (url) not cacheable [closed]
- Php file that doesn’t recognize wordpress functions
- Front end file upload returning wrong attachment url
- WordPressUser Submission Form
- Get value from db for custom contact form
- Display multi-select box choices in a bullet list [closed]
- Page Options Saving But Not Updating In Backend
- What should I write in the post action of this front end post form?
- Custom forms with HTML
- Testing a Form’s Zipcode Field with Regular Expressions to Determine WordPress Page Behaviour
- Using Ajax to submit a form, and run a SQL Select query based on user input from the form
- Cascading dropdown select search based on Parent Page & Child Page
- HTML Form Question
- Is it secure to use SMTP password in .php file in WordPress website?
- WordPress Custom Form – Getting Query Vars, Weird Glitch?
- $_POST returning empty values
- Trying to update Woocommerce meta values
- How to send custom form submissions to WordPress Database?
- Custom PHP form needs refresh to load page correctly
- Form from within a page
- I want it to detect the duplicate comment and give a warning on the same page
- Updating user meta adds string count to value?
- PHP multiple forms, same page, isset($_POST[]) not working?
- I want to retrieve the email or username data entered for password reset, but failed. how can I do it?
- “Class Not Found” in HTML Form Target PHP File that contains the class
- How to change this ajax function to submit to the default wordpress content area instead of the custom field ‘seller notes’?
- Confuse between forms and tables
- wordpress contact form messages not sending although it saying they were sent successfully with this php code
- How to create a widget with a populated dropdown?
- Store user form submitted information in post type
- Implement jQuery Smart wizard
- Using a PHP form, get the page title or any other element in the sent e-mail
- form submission reverts to index.php template
- Javascript / PHP – closing the loop
- How do I stop my form from adding code to current page URL instead of re-directing. Been stuck for days
- Updating the database after parsing CSV document
- custom search query database in child theme
- Creating a WordPress addon for ContactForm7 submission (.XML file export)
- Using transients to store form notifications
- Insert data from form to database
- not able to access $_POST on backend profile update
- Creating wordpress user registration form
- Custom Plugin Develoment, Form Action
- wordpress form action page not found
- Adding action item to admin users table and sending email
- Trouble with checked() for array of multiple checkboxes
- If input field has value Require another field – PHP
- Custom HTML form using PHP – help with ajax/username validation
- WordPress default contact form
- Form direction to .php on localhost
- Form not working as it should in WordPress, but in a normal HTML site it does
- Submitting my form to the database and then redirecting to payment site
- Passing link parameter values to form
- Processing forms with php to wordpress database
- Ajax call URL 404’ing when pushed to staging server
- Update only some custom user fields
- Post from front end form to post_meta
- Passed variable gets undefined variable error on insert on next page
- Accessing values entered via form – try again
- Nonce fail after second submit attempt
- Use get_option with $emailTo on contact page
- How to set up an auto delete post?
- Dynamic form variables for post meta
- Trying to display user meta by “name” – not by “ID”
- Styling admin page rows in order of importance (checkboxes)
- Headers for Contact Form are wrong
- Display default WordPress login/registration form into a modal window
- Using Nonce for my Form
- Trouble using wordpress functions in a pop-up modal form