[英]contact form in email not returning values
I'm using CKEditor
to create a html mailer
in which a contact form is being sent to email. 我正在使用
CKEditor
创建一个html mailer
,其中将联系表发送到电子邮件。
The problem is, there is no value being received on submission of that form in email. 问题是,在电子邮件中提交该表格没有任何价值。
Contact Form in E-Mail (code) 电子邮件中的联系表格(代码)
<form action="http://techindiainfotech.com/mail.php" method="post" name="test">
<p>Your Name: <input maxlength="75" name="name" size="75" type="text" /></p>
<p>Mobile Number: <input maxlength="10" name="mobile" size="10" type="text" /></p>
<p>Business Name: <input maxlength="100" name="business" size="100" type="text" /></p>
<p><input name="sub" type="submit" value="Submit" /></p>
</form>
Handler - mail.php 处理程序-mail.php
if ($_POST['sub'] != '') {
unset($_POST['sub']);
echo "Details received:<br>";
foreach ($_POST as $val) {
echo "$val<br>";
}
} else {
header("Location: http://www.techindiainfotech.com/files/contact_us.php");
exit();
}
Screenshot from gmail's Message Text Garbled gmail的消息文本乱码的屏幕截图
if ($_POST['sub'] != '') {
unset($_POST['sub']);
The above code means: if $_POST['sub']
is not an empty string, evaluate the statements below. 上面的代码意味着:如果
$_POST['sub']
不是一个空字符串,请评估以下语句。
If your form wasn't submitted, $_POST['sub'];
如果您的表单未提交,则
$_POST['sub'];
will be undefined and PHP will throw an error saying Undefined index
. 将是未定义的,PHP将抛出错误消息
Undefined index
。
I'd use isset()
instead to properly check if the form was submitted or not. 我会使用
isset()
来正确检查表单是否已提交。
if (isset($_POST['sub'])) {
# code ...
}
The following should work: 以下应该工作:
if (isset($_POST['sub']))
{
unset($_POST['sub']);
echo "Details received:<br>";
foreach ($_POST as $val)
{
echo "$val<br>";
}
}
Your form is so simple and the $_POST
loop, that it narrows down the error sources: 您的表单是如此简单,并且
$_POST
循环如此,它缩小了错误源的范围:
print_r($_POST);
print_r($_POST);
at the beginning of mail.php Update: 更新:
name
attributes or renders the form in any other invalid form (don't think that's the problem) name
属性标记它们,或以任何其他无效形式呈现该表单(不要认为这是问题所在) I copied your sample code onto my webserver and it's working. 我将示例代码复制到了我的网络服务器上,并且可以正常工作。 You might have something in your real code that doesn't appear in the code above.
您的真实代码中可能有一些未出现在上面的代码中的东西。
Everything was fine except for the one, the form action
attribute. 除了表单
action
属性外,其他一切都很好。
I'm submitting the form to http://techindiainfotech.com/mail.php
but due to .htaccess
it is being redirected to http://www.techindiainfotech.com/mail.php
and that's why the request has been lost (I'm not getting the appropriate word here). 我正在将表单提交到
http://techindiainfotech.com/mail.php
但是由于.htaccess
,该表单已重定向到http://www.techindiainfotech.com/mail.php
,因此该请求已丢失 (我在这里没有得到合适的词)。
So, I just need to change in my action
attribute which is, submit my form to http://www.techindiainfotech.com/mail.php
not to http://techindiainfotech.com/mail.php
. 因此,我只需要更改
action
属性即可,即将表单提交到http://www.techindiainfotech.com/mail.php
而不是http://techindiainfotech.com/mail.php
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.