已解决 - 权限
我想通过我的调试过程,以便它可以帮助其他任何人通过同样的事情... 1)我擦除了两个页面,并替换为我知道工作的代码。 2)然后我逐个更改了表单,直到我得到它我想要的并继续测试3)然后我完全复制了当前的php文件并将我的表单重定向到它。 4)它失败了...我将权限更改为655并且wallah工作了。现在我可以去破解PHP代码以获得我想要的东西。感谢所有的建议,你肯定带领我走向我的解决方案
的解决
我在网站上有两个单独的入口表格。摄入表单1完美运行。我接受,命名,发送电子邮件和评论,并通过sendmail脚本发送。
我还想要一个铅捕获的入口表单来跟踪那些想要访问演示视频的表格,所以我从表单中修改了代码(用于新页面),然后创建了另一个名为videoform.php的php文件 - 这是基本上只是我的sendmail.php文件的修改版本。
当我填写表单时,当我点击提交时它什么都不做。它验证,因为它不允许您在任何字段中输入空值,但我不确定我缺少什么。它是简单的东西(我绝不是PHP可靠的)或者我可以不这样做吗?
这是表格和php:
<div class="message"></div>
<form action="./php/videoform.php" method="POST" id="contact-form">
<p class="column one-half">
<input name="name" type="text" placeholder="Your Name" required>
</p>
<p class="column one-half">
<input name="email" type="email" placeholder="Your Email" required>
</p>
<p class="column one-half">
<input name="phone" type="text" placeholder="Your Phone" required>
</p>
<p>
<input name="submit" type="submit" value="Submit">
</p>
</form>
</div>
这是PHP
<?php if(!$_POST) exit;
$to = "xxxxx@example.com";
$email = $_POST['email'];
$name = $_POST['name'];
$phone = $_POST['phone'];
$content = $_POST['content'];
$subject = "You've been contacted by $name";
$content = "$name filled out a request to view the online videos:\r\n\n";
$content .= "Phone: $phone \n\nEmail: $email \n\n";
if ($success) {
header("Location: /videos.html");
exit;
} else {
header("Location: /video-form.html");
exit;
}
?>
我对许多编码格式感到满意,但在PHP方面我很弱。任何见解都会受到赞赏,让我更好地理解PHP。
用于比较的工作脚本
表
<p class="column one-half last">
<input name="email" type="email" placeholder="Your Email" required>
</p>
<p class="clear">
<textarea name="comment" placeholder="Your Message" cols="5" rows="3" required></textarea>
</p>
<p>
<input name="submit" type="submit" value="Comment">
</p>
</form>
</div>
PHP sendmail.php文件
<?php if(!$_POST) exit;
$to = "xxxxx@example.com";
$email = $_POST['email'];
$name = $_POST['name'];
$comment = $_POST['comment'];
$subject = "You've been contacted by $name";
$content = "$name sent you a message from your enquiry form:\r\n\n";
$content .= "Contact Reason: $comment \n\nEmail: $email \n\n";
if(@mail($to, $subject, $content, "Reply-To: $email \r\n")) {
echo "<h5 class='success'>Message Sent</h5>";
echo "<br/><p class='success'>Thank you <strong>$name</strong>, your message has been submitted and someone will contact you shortly.</p>";
}else{
echo "<h5 class='failure'>Sorry, Try again Later.</h5>";
}?>
答案 0 :(得分:3)
来自你的php:
//...
$content = "$name filled out a request to view the online videos:\r\n\n";
$content .= "Phone: $phone \n\nEmail: $email \n\n";
if ($success) {
header("Location: /videos.html");
exit;
} else {
//...
你永远不会定义$ success。由于它没有值,if ($success)
失败,并且它总是进入语句的else
部分。看起来你错过了类似$success = mail($to, $subject, $content);