I want to insert data into database table through custom php form in wordpress. I don't want to use/create plugins/hooks. just simple form for client so he can edit himself whenever he want.
I tried
if($_POST['submit'])
{< submit to db >
} else {
< display html form ><br>
}
with action="" . this redirect to the same page without any error on page + in console. javascript validations on fields are working perfect.
I tried another solution by creating a php file in themes folder, and setting action="../that_file.php", which gave 404 error.
Any other solution?
You should use Formidable or ACF to build your form, you will lose less time for any update on your form, also, you could have a view in the dashboard to manage your user's response, that should be easier for you.
Thanks guys I found a way. I use Contact form 7 for form and CFDB plugin to save that form data to db.
I had to send confirmation email after submission so Contact form 7 did it for me.
Related
I have created a module where a form is added to the admin view order page using the function:
public function hookDisplayAdminOrderSide($params)
The form on that page posts data to the same url:
<form method="POST" action="#">
I then use the hook "hookDisplayAdminOrderTop" to capture the post data and submit to the API (this is done when the page posts to itself and reloads). I then collect the results of the api and assign it to $result. This then allows me to echo if the submission worked etc
This all works fine.
However, I'm pretty sure this is not the correct way to do this with Prestashop. Usually with a form I would send the user to another page e.g.
<form method="POST" action="/submit.php">
Then on that page once the data has been submitted, redirect the user to a confirmation page.
Whilst what I have done is working, what is the correct way to do this with prestashop (p.s. I'm new to Prestashop, this is my 1st module) so try and keep the advice easy to follow?
I looked at the other forms on the page e.g. status update form and private note form, they all seem to post to the same url but with a slight change e.g.
index.php/sell/customers/2/set-private-note
index.php/sell/orders/2/status
index.php/sell/orders/2/send-message
I'm assuming the "set-private-note" and "status" etc are linked to some form for submission form in the PS back end.
Finally, on a second note, if you create a 2nd php file in the module root folder, what needs to be added to keep this secure e.g. so someone outside of the admin can't run it etc?
Any help would be greatly appreciated.
Thanks in advance :)
I am using gravity form plugin on my WordPress website for client registration. Currently I am getting notification on email. I want to save the field data to csv/text file after hitting submit. Please someone suggest me how to do that.
Thanks :)
There has a hook gform_after_submission which executes after form submitted. You can add your own action where you will get all the form data and then you can create csv/text file there. Here is the documentation.
https://www.gravityhelp.com/documentation/article/gform_after_submission/
There has a hook gform_after_submission which executes after form submitted as You can add your own action/function where you will get all the form data and then you can create csv/text file there. Here is the documentation. https://www.gravityhelp.com/documentation/article/gform_after_submission/
Hello I'm trying to get back into coding and I've hit a problem that I need some help with. I've created a form with HTML5 so it has the built in required fields and i can get this to post to a database but I currently have the POST on a different page so that I can just have words saying Submit complete but currently you can just go to that submit page over and over and it will just send off blank fields to my database so I wanted to check the post as a whole to see if the whole thing is empty then not submit but I don't know if this is the best way to do it.
thanks if you need my current PHP just shout and ill put it on.
First of all validate your form fields with Javascript or Jquery validation for client side validation. Its very easy, you can use jquery validation plugin eg.
Jquery Form Validation
For Server side validation you can use php functions like isset($_POST['field_name']) and !empty($_POST['field_name'])
For PHP form validation please visit the link for reference : PHP Form Validation
I'm transitioning from CodeIgniter to WordPress. Still trying to wrap my head around WordPress plugin development... seems pretty easy, but one thing I can't figure out is: where do I send the form data? In CodeIgniter, you could simply create another method in the controller and point the form action there, but it seems WordPress plugins are a little different.
Depends on how your plugin is generating the form. Typically you do it by registering a shortcode, something like [my_form] that you can insert into a page or post where you want the form to appear.
In your plugin code the form action can be blank -- simply reload the same Wordpress page. Your form info. will be in the global $_POST and your plugin can then process the data.
So your plugin shortcode function would have something like:
if(isset($_POST['my_plugin_form_field'])){
/* code to process the form info and generate a message on screen
}
else{
/* the form hasn't been submitted yet so here is the code to display it
}
I have a WordPress site with a form that I need to add a captcha to. The form isn't it's own template or even on it's own page but it is a single php file that is included on all of the pages. The actual form is in the shape of a drop down menu. When a user clicks on the "request info" link, the form drops down from the navbar. Do to the way it is set up I can't use a WordPress plugin.
Normally, I could I just add a php captcha script and be done with it but the form action is set to post to an external website. When the visitor submits the form, it goes to another website that collects the info, as you can see here:
<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST" name="contact" id="contact" onsubmit="return checkform(this);">
Because the form isn't verified with a php file on the sites server, I don't know how to verify the captcha and get it to work. Does anyone have any suggestions?
The only way to do it would be to make an ajax call on submit to your server where you check the captcha code. If the code is valid, then submit the form. If it isn't display the error and don't allow the form to submit.
If you are using Recaptcha, check this SO: using reCAPTCHA with ajax....javascript loading problem
If a general Captcha is what you are doing: jQuery ajax validate captcha
The answers are more focused that what you are looking for, but will at least get you pointed in the right direction.