#Astro - Submit form post can be used in component as well ?

1 messages · Page 1 of 1 (latest)

versed ridge
#

Hi,
Submit form post can be used in component as well ? I tried to use that in component and it is being submitted twice instead of one.

ashen terraceBOT
#
Quiet in here?

It looks like no-one has responded to your question yet. People might not be available right now or don’t know how to answer your question. Want an answer while you wait? Try asking our experimental bot in #1095492539085230272.

tame holly
#

Hi. I managed to send a contact form with PHP in Astro. I simply created a contact form in a kontakt.astro page and then referred to the kontakt.php in the form tag via the action attribute. However, you must note that the PHP is in the public folder and the content of the public folder is copied 1:1 to the main directory during the build. Therefore you don't have to specify the "correct" path in the action, but the path after creating the build. Works very well, is only sent once to me and should be safe if the php is written correctly

versed ridge
#

Hi Andreas, thank you for the help. But, my Question is related to how can we use form post in Astro component instead of page, as I'm facing an issue where form being submitted twice as my form is inside Astro component and not in page.

tame holly
#

Alternatively (I have never tried it and you would have to check beforehand whether it would be safe) you could pack the form on an extra page and then integrate it via an iframe as a modal or something. However, faith would not be recommended for security reasons