I need to build a form with a just a few fields: username, password and submit button.
Why do I need this form? In my website there is a link to let some users log into another website. In other words, I want to display a login form inside my site theme to enter login data and submit.
My question: Is there a way to send my built in form values to that form (another website form) then submit automatically?
Well, there are a few ways you can approach this.
You can have the form fields on your site but the form itself points to the desired website. E.g
<form action="http://www.other-site.com/form.php">
<input type="text" name="username" />
// and so on
Or you can grab the form data on server side and use CURL to send the data.
Related
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.
I have a simple lead collection form that asks for the user's zip code on the first page, and then based on which state that zip code is in it sends them to the second page of my form with the zip code already populated, or to another site. In my pre-CodeIgniter days this was a very simple thing to do, but I'm not sure how to send the zip code data from my routing script to the second page of my form and not have it mess with CI's form validation. The second page of my form currently looks like this:
<input type="text" name="zip"value="<?php echo set_value('zip'); ?>" />
So if the user submits invalid data on the second page, the form reloads with all the data pre-populated (using CI's set_value function). But what needs to happen is something like...
IF the user comes from page 1 of the form, populate the zip code field using the data from form 1. ELSE, re-populate it after a failed form submit.
Is there some way for set_value to intelligently work in both situations? If not, do I need to use a different function? I'm also not sure how to pass the zip code data from my routing script to the controller for page 2 of the form.
I'd really appreciate any help. THANK YOU!!
I am building a web service in which a user can login to a backend, submit a form and then other users will be able to see this information on the front-end of the web service.
The data is submitted to the PostgreSQL database fine BUT on the second submission of the form (users can go back to the form and update their information if neccessary) if there is a blank field in the form, the existing data in the form is overwritten with blank data.
How can I avoid this? I think it would be good to populate the form fields with data from the database and allow the user to edit the form like that but I am unsure how to implement this using PHP. At the moment a user would have to fill out the form in full over and over to prevent this kind of data loss.
Could someone give me an idea or point me in the right direction?
pre-fill the form fields with earlier entries from the DB
<input type="text" value="<?php echo $fname;?>" name="first_name" id="first_name" />
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.
I am using a form to register the user on my website and i have a captcha security on it. Everything is working well and good but the only problem that i am facing is that if i enter a wrong captcha or somehow the page refreshes , all the data entered by the user is wiped out.
what i wish to achieve is that even if the captcha entered is wrong and the form is submitted , the form should have all the fields intact as the user filled in excluding the captcha field.
How can this be done? My form is html and the processing page is php
You can populate the value attribute of your form inputs;
<input type="text" name="username" value="<?php
if (!empty($_POST['username'])) {
echo htmlspecialchars($_POST['username']);
}?>"
/>
You need to set the form action to the current page. As long as there are errors, the same script will get called and this script may fill in the form values as described in the other answers. Only on success you will redirect the user to another page.