带有 Firebase 托管的简单 PHP 联系表 [英] Simple PHP contact form with Firebase hosting

查看:15
本文介绍了带有 Firebase 托管的简单 PHP 联系表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下方法测试 PHP 是否可以在我的 Firebase 托管上运行:

I'm trying to test out if PHP works from my Firebase hosting using the following:

(index.html)

(index.html)

<form action="welcome.php" method="post">
   <input type="submit">
</form>

(welcome.php)

(welcome.php)

<?php

   $to = "my@email.com";
   $subject = "My subject";
   $txt = "Hello world!";
   $headers = "From: dummy@email.com";

   mail($to,$subject,$txt,$headers);

?>

每次我尝试时,浏览器都会不断尝试打开 PHP 文件而不是处理它.Firebase 服务器托管上是否启用了简单的 PHP 来处理这样的简单表单?如果我能让它以这种方式工作,我将正确构建表单,包括验证等.

Every time I try this the browser keeps on attempting to open the PHP file rather than processing it. Is simple PHP enabled on the Firebase server hosting to process a simple form like this? If I can get it to work this way, I will be building the form out correctly including validation etc.

谢谢,

推荐答案

来自 Firebase 托管网站(强调我的):

我们通过安全的 SSL 连接提供您的所有静态内容(html、js、图像等),并在 CDN 上提供.

We deliver all of your static content (html, js, images, etc.) over a secure SSL connection and serve it on a CDN.

Firebase 托管用于托管静态资产.Firebase 目前不提供在 Firebase 的服务器上执行您的代码的任何方式.

Firebase Hosting is for hosting static assets. Firebase currently doesn't offer any way to execute your code on Firebase's servers.

更新 (2018-08-08):您现在可以运行 Node.js/JavaScript 代码,但 将您的 Firebase 托管项目连接到 Cloud Functions + Firebase 托管.但这仍然不允许您运行 PHP 代码.

Update (2018-08-08): You can now run Node.js/JavaScript code but connecting your Firebase Hosting project to Cloud Functions + Firebase Hosting. But that still won't allow you to run PHP code.

这篇关于带有 Firebase 托管的简单 PHP 联系表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆