表格不适用于特定领域

时间:2015-10-24 23:07:11

标签: php forms browser

我在this website中添加了一个简单的表单,对于这个特定的域名,它不起作用。我已尝试过不同的域名,效果很好。 任何人都可以帮我弄明白问题是什么?任何人都有第二种符合此规范的表格吗?



<?php

$name = $_POST ['name'];
$mobile = $_POST ['mobile'];
$email = $_POST ['email'];
$subject = $_POST ['subject'];
// $message = $_POST ['message'];
$message = $_POST['message'] . "\n Contacto: " . $_POST['mobile'];
$to = "rodolfovieiradias@gmail.com";
// $subject = "" . $mobile;

mail ($to, $subject, $message, "From: " . $email);
echo "<div style ='font:14px Arial, Helvetica, sans-serif;font-weight: bold;line-height: 15px;color:white;background-color: green;padding: 5px;text-align: -webkit-center;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;'>Your message has been sent!</div>";
?>
&#13;
<form action="backend/form_processEN.php" method="post" name="contact_form" id="contact_form" target="myIframe" autocomplete="on">

											<fieldset>
												<div>
													<label for="name" accesskey="U">Name</label>
													<input name="name" type="text" id="name" placeholder="Enter your name" required="required" />
												</div>
												<div>
													<label for="mobile" accesskey="P">Phone</label>
													<input name="mobile" type="tel" id="phone" size="30" placeholder="Enter your phone number" required="required" />
												</div>
												<div>
													<label for="email" accesskey="E">Email</label>
													<input name="email" type="email" id="email" placeholder="Enter your Email Address" pattern="^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$" required="required" />
												</div>
												<div>
													<label for="subject" accesskey="W">Subject</label>
													<input name="subject" type="text" id="subject" placeholder="What&acute;s the subject?" required="required" />
												</div>
												<div>
													<label for="comments" accesskey="C">Message</label>
													<textarea name="message" cols="40" rows="3" id="comments" placeholder="Leave your message..." spellcheck="true" required="required"></textarea>
												</div>
											</fieldset>

											<input type="submit" name="submit" class="submit" id="submit" value="Submit" >
											<iframe name="myIframe" frameborder="0" border="0" cellspacing="0" style="border-style: none; margin-left: 65px; width: 240px; height: 40px;"></iframe>
											
										</form>
&#13;
&#13;
&#13;

由于

1 个答案:

答案 0 :(得分:0)

您可能需要确保“发件人”电子邮件确实在您发送的服务器上 - 即不是@ gmail.com地址。

这很好地解释了邮件,并展示了如何为mail();添加“回复”。 http://foundationphp.com/tutorials/email.php

请记住清理任何文本字段输入信息以避免注入攻击。

您也可以尝试在php中设置sendmail_from ini设置 ini_set("sendmail_from","you@yourserver.com"); 把它放在你的PHP顶部。

PHP Mailer也是一种可靠的电子邮件替代方法,我个人更喜欢。使用PHPMailer:https://github.com/PHPMailer/PHPMailer使您能够在电子邮件中添加“回复”,从而避免将回复电子邮件返回到您的服务器并将其发送给您的访问者。