Streaming live at 10am (PST)

Form submissions redirects to target url


#1

Hi,

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.

Please help me!

Read-only link


#2

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.


#3

Thanks for answering @Waldo!

Yes, I have tried putting the following values in the field "Redirect URL":

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?


#4

@Waldo By the way, is the POST request sent with AJAX? Please don't miss my reply above though :slightly_smiling:


#5

Hey @Rawland_Hustle you might want to add in a header("Location: /path/to/redirect");` to your PHP file to re-direct users on the form submission.

I think that this article may be helpful for you: http://www.w3schools.com/php/func_http_header.asp

Regards,
Anna


#6

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?


#7

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.


#8

@Waldo Oh, I see. Thanks!

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.


#9

Hey @Rawland_Hustle you may find this post helpful in guiding you on your form setup after exporting your site: http://forum.webflow.com/t/custom-form-on-exported-website/10790/21?u=waldo :smiley:


#10

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!


#11

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.