i want to add a page with html data to show form and get input from user,store it to database and after successful query show next page with massage that the data is inserted successfully.
-
And what have you tried so far?ngearing– ngearing2015-09-11 06:29:17 +00:00Commented Sep 11, 2015 at 6:29
-
We expect some degree of research and effort from your side. We do not code projects for you, but we will help you with a specific problem while developing your projectPieter Goosen– Pieter Goosen2015-09-11 06:49:38 +00:00Commented Sep 11, 2015 at 6:49
-
You have two answers, very broad and not that specific to your whole task. But certainly they both lead to a solution: one with custom code in a template, that can be published with WordPress itself in any page that you want, another one showing how to load WP funcionality in a separate script giving you access to all functions. A bit of effort on your part taking from that answers could spark more interest and helping you in case you get stuck at some point.Jesús Franco– Jesús Franco2021-12-15 07:00:59 +00:00Commented Dec 15, 2021 at 7:00
2 Answers
Firstly your question shows no research or effort whatsoever. Also it isn't elaborated efficiently.
From what I gather you want a page with some code in wordpress. There are multiple ways to do it.
Easiest way would be to create a new page template in your theme file. Go to your active theme folder and create a new page template
<?php
/* Template Name: Form Page Template */
if($_POST['xyz') {
//Post form processing and data insertion here
}
?>
<form name="abc" method="POST" action="">
<input type="text" name="xyz" />
<input type="submit">
</form>
<!---You can add any html or PHP code to Page template ---->
After saving the template file. Go to pages->add new page in dashboard and create a new page . From page attributes drop down choose the page template you just created.
As I understood you want an external PHP page that can access WordPress functionality without showing any output or template elements. In this case you just need to include wp-load.php to your code. Supposing that Wordpress were installed your root folder just simply add
require_once($_SERVER['DOCUMENT_ROOT'] . '/wp-load.php');