PHP code cannot run directly in the Webflow embed component because Webflow is a static hosting platform that does not support server-side code like PHP.
1. Why PHP Doesn’t Work in Webflow
- Webflow only supports HTML, CSS, and JavaScript. It is a frontend-focused platform without server-side processing capabilities.
- Custom code embeds in Webflow only support client-side code (like JavaScript or iframe integrations).
- PHP code requires a server with a PHP interpreter, which Webflow’s servers do not provide.
- Use Webflow's built-in form handling: Webflow provides native support for forms, including submissions, email notifications, and integration with third-party tools.
- Use third-party form services: Embed services like Formspree, Basin, or Zapier to handle form submissions via JavaScript.
- Integrate with external PHP scripts: You can host your PHP script on an external server and send Webflow form data to it using a form action URL or
fetch()
via JavaScript.
3. When Exporting Code is Necessary
- If your form processing requires custom PHP logic, such as sending emails via
mail()
, interacting with a database, or validating data server-side, then: - Export your Webflow project.
- Host it on a PHP-enabled server, such as those provided by Bluehost, SiteGround, or any LAMP stack host.
- Add your PHP code to the exported files (e.g., contact-form-handler.php) for full functionality.
Summary
No, PHP code cannot be used directly in an embed in Webflow. You must export and host your site elsewhere if your form needs PHP or other server-side functionality. For most users, native Webflow forms or third-party services will suffice.