I’ve set up a form that, on submission, posts the input data to a PHP-file. This works fine, but for some reason webflow redirects me to the target URL after submission. Just put in some random data here and press the button to see what I’m talking about: http://fortgjort.webflow.io/skapa-kategori
I don’t want this behavior. Ideally I don’t get redirected at all, but if I have to, I’d like to be redirect to my page ‘kategorier’ but I can’t get that to work either.
Hey @Rawland_Hustle have you tried adding in a re-direct URL for the form submitters to be re-directed to? The current post action looks like it’s sending users to that php page.
I still land on the PHP page. Am I missing something? Just to be clear: I’m running my site from webflow.com while the PHP page is on my own domain. I don’t know if that has anything to do with it.
BUT, I really don’t want to redirect the user at all. That’s plan B. What I really want is to show the Success or Error message depending on the result of the http post request. What’s the criteria for showing the Success message vs. the Error message?
Thanks @sabanna! I got the user to stay on (get redirected to) the Webflow page. Is this a workaround or is this how it’s supposed to be done? Also, how to I get the Webflow page to show the Success or the Error message depending on the response from the PHP file?
Hey @Rawland_Hustle excellent question! Since you are Posting your form information elsewhere, the error/success message should be coming from your Post source (in this case your PHP side), since the form information is now being submitted to Webflow but going to your PHP file instead.
I really want to do this with AJAX. Wouldn’t it then be better for me to remove all the actions Webflow does when the user clicks the submit button, and instead tie my own javascript to the submit button after I’ve exported the code from Webflow? If so, how do I do that? Adding '# or # to the action field doesn’t help. I just want to keep the HTML code of the form.
Thanks @Waldo and @sabanna! Unfortunately I find this too complicated. It would have been nice if Webflow let me create just the HTML code for a form with all it’s input fields without automatically attaching Javascript functions to it.
For this particular site I’ll write the HTML and the Javascript myself. Webflow is a great tool in most other cases though. And thanks for taking your time to help me with this!