PHP邮件功能不起作用。如何抓取DIV的文字?

时间:2016-04-21 07:41:00

标签: php php-gettext

试图找到解决方案,请帮忙。首先找到下面的代码。

当我删除'右变量'它工作正常。但我必须在每封电子邮件中添加此div的文本。我试过.text()和.html()都没有用。请帮我如何在php邮件功能中获取div的文本。

http://www.ankooverseas.com/select_university

2 个答案:

答案 0 :(得分:2)

我会使VarData成为一个对象,以使编码操作更容易:

var VarData={studentName: student_name, studentContact: student_contact, studentEmail: student_email, right: right};

然后在您的PHP代码中,您可以轻松地从$_POST获取变量:

$student_name=$_POST['studentName'];
$student_contact=$_POST['studentContact'];
$student_email=$_POST['studentEmail'];
$right=$_POST['right'];

请注意$_POST是由Web服务器创建到Php上下文的php全局变量,它包含HTTP POST请求中提交的数据。该变量是一个数组,具有HTTP POST字段名称的键和字段值的值。因此,以$_POST['#right']访问此内容毫无意义,因为没有名为#right的字段。什么也没有意义,因为这不是jQuery,是$_POST['#right'].html()的调用 - 数组上没有名为.html()的对象方法,因为a)它们不是对象b)数组不必须包含html代码,它们是通用语言结构。

您的代码无效的最可能原因是因为您的div内容未在VarData字符串中进行网址编码。使VarData成为对象无需您对数据进行编码。

答案 1 :(得分:0)

你不能在php中使用jquery。如果你想要POST数据,你应该使用jquery设置一个隐藏的textarea与该数据,你将能够在处理表单的PHP脚本中使用它。如果您不希望用户在textarea中查看内容,我会假设隐藏。

<textarea name="right" cols="20" rows="20" style="display:none;"></textarea> // the view

$right = $_POST['right'];// access that content from the textarea in your php file that processes the form