【发布时间】:2015-07-31 07:56:14
【问题描述】:
我正在使用 xampp (apache) php 并想在本地测试我的 html 电子邮件表单。当我在form 标签中使用这个action 时,它可以工作(我收到“感谢您联系我们”的确认):
<form id="contactus" action="http://www.html-form-guide.com//files/contact-form/simple-form-1-1/contactform.php" novalidate method="post" accept-charset="UTF-8" >
注意:此网址用于action是从一个指导电子邮件表单设计的网站获得的。
但我无法正确编码 action 以使其使用我的本地 .php 文件运行。我已经尝试了所有这些(基于 stackoverflow 帖子中的建议),但都没有奏效:
action="contactform.php"action="http://localhost/contactform.php"action="<?php echo site_url('contactform'); ?>"
我的 .php 和 .html 电子邮件文件位于同一个文件夹中。目录路径为:c:\xampp\htdocs\contactform.php & c:\xampp\htdocs\Contact us.html
我测试的方式是使用 Cntrl+O 在 Chrome 中打开 Contact us.html。我可以看到电子邮件表格。当我输入姓名、电子邮件地址和虚拟消息时,它在我使用 action="http://www.html-form-guide.com//files/contact-form/simple-form-1-1/contactform.php" 时有效,但不适用于上面的 1、2 和 3。感谢您的帮助。
最后,使用 localhost/contactform.php 打开 .php 文件没有问题。
更新:如果这有帮助,请查看我的 XAMP 控制面板中的脚本:
22::37:25 [main] Initializing Control Panel
22::37:25 [main] Windows Version: Windows 8 64-bit
22::37:25 [main] XAMPP Version: 5.6.8
22::37:25 [main] Control Panel Version: 3.2.1 [ Compiled: May 7th 2013 ]
22::37:25 [main] You are not running with administrator rights! This will work for
22::37:25 [main] most application stuff but whenever you do something with services
22::37:25 [main] there will be a security dialogue or things will break! So think
22::37:25 [main] about running this application with administrator rights!
22::37:25 [main] XAMPP Installation Directory: "c:\xampp\"
22::37:25 [main] Checking for prerequisites
22::37:25 [main] All prerequisites found
22::37:25 [main] Initializing Modules
22::37:25 [Apache] Initializing module...
22::37:25 [Apache] Checking for module existence...
22::37:25 [Apache] Checking for required tools...
22::37:25 [Apache] Checking for service (name="Apache2.4"): Service not installed
22::37:25 [Apache] Service Path: Service Not Installed
22::37:25 [Apache] Checking default ports...
22::37:25 [mysql] Initializing module...
22::37:25 [mysql] Checking for module existence...
22::37:25 [mysql] Checking for required tools...
22::37:25 [mysql] Checking for service (name="mysql"): Service not installed
22::37:25 [mysql] Service Path: Service Not Installed
22::37:25 [mysql] Checking default ports...
22::37:25 [filezilla] Initializing module...
22::37:25 [filezilla] Checking for module existence...
22::37:25 [filezilla] Checking for required tools...
22::37:25 [filezilla] Checking for service (name="FileZillaServer"): Service not installed
22::37:25 [filezilla] Service Path: Service Not Installed
22::37:25 [filezilla] Checking default ports...
22::37:25 [mercury] Initializing module...
22::37:25 [mercury] Checking for module existence...
22::37:25 [mercury] Checking for required tools...
22::37:25 [mercury] Checking default ports...
22::37:25 [Tomcat] Initializing module...
22::37:25 [Tomcat] Checking for module existence...
22::37:25 [Tomcat] Checking for required tools...
22::37:25 [Tomcat] Checking for service (name="Tomcat7"): Service not installed
22::37:25 [Tomcat] Service Path: Service Not Installed
22::37:25 [Tomcat] Checking default ports...
22::37:25 [main] Enabling autostart for module "Apache"
22::37:25 [main] Enabling autostart for module "MySQL"
22::37:25 [main] Starting Check-Timer
22::37:25 [main] Control Panel Ready
22::37:26 [Apache] Autostart active: starting...
22::37:26 [Apache] Checking default ports...
22::37:26 [Apache] Attempting to start Apache app...
22::37:26 [Apache] Executing "c:\xampp\apache\bin\httpd.exe"
22::37:26 [Apache] Return code: 0
22::37:26 [mysql] Autostart active: starting...
22::37:26 [mysql] Checking default ports...
22::37:26 [mysql] Attempting to start MySQL app...
22::37:26 [mysql] Executing ""c:\xampp\mysql\bin\mysqld.exe" --defaults-file="c:\xampp\mysql\bin\my.ini" --standalone"
22::37:26 [mysql] Return code: 0
22::37:26 [Apache] Status change detected: running
22::37:26 [mysql] Status change detected: running
【问题讨论】:
-
第一个选项应该有效
-
注意那个'zzz'文件夹...
-
如果您直接使用 chrome 打开 .html 文件,它将无法正常工作。启动服务器。并转到 localhost/contactus.html
标签: php html forms apache xampp