【问题标题】:php form isn't mailing [closed]php表单没有邮寄[关闭]
【发布时间】:2012-10-02 23:57:06
【问题描述】:

我在一个网站上有一个 div,点击它时会用一个表单替换当前页面的内容(表单是用 javascript 创建的,是的,我知道这很奇怪)。这是一个非常简单的表单,一个文本输入一个文本区域和一个按钮类型=提交。在提交时,我让它调用我的 php 邮件页面 (form.php)。什么都没发生。有人知道为什么吗?

这是 PHP:

<?php
$to = "theemail@yahoo.com";
$subject = "Someone has contacted you from your website";
$message = $_POST['theMessage'];
$from = $_POST['theEmail'];
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
header( 'Location: http://www.thesite.com/index.php' ) ;
?>

这是我的 js:

var theForm = '\
<from action="../form.php" method="post"> \
    <div class="title blueTxt">Your Email Address:</div>\
    <input type="text" name="theEmail"> \
    <div class="title blueTxt">Your Message:</div>\
    <textarea name="theMessage"></textarea><br> \
    <button type="submit">Send</button>\
    \
</form>';

$('a .callToAction').on('click',function(){
    $('.content').html(theForm);
});

我尝试了几件事,但都没有奏效:在js中更改form.php的路径;使用输入类型=提交而不是按钮。这些都没用,有什么想法吗?谢谢!

【问题讨论】:

  • 您确定确实达到了form.php 吗?检查您的访问日志。 form.php 有错误吗?
  • 对于一个...您的form 标签显示&lt;from&gt;...将其更改为&lt;form ...。尝试开始。

标签: php javascript forms email


【解决方案1】:

在我看来这是一个拼写错误:

从行动...

应该是:

表单操作...

【讨论】:

  • 哇,我讨厌我的生活。谢谢。
  • 轻松搞定,今天早些时候我浪费了整整一个小时,因为我的代码有 == 或者 != 某处 :)
猜你喜欢
  • 2023-03-21
  • 1970-01-01
  • 2016-05-12
  • 1970-01-01
  • 2013-04-26
  • 2019-03-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多