The form lives at fictiveapp.com/ It's the second one with Name, Email, and Message.

该表单位于fictiveapp.com/。这是第二个名称,电子邮件和消息。

I'm running into two issues.

我遇到了两个问题。

  1. 405 error - I 'resolved' this by adding a trailing slash

    405错误 - 我通过添加尾部斜杠来解决这个问题

  2. 404 error - when adding the trailing slash to resolve the previous issue i get a 404 error instead. I'm very new to PHP and am unsure how I'm supposed to link the files. I thought it would be the same as linking all other html files on a site, apparently not.

    404错误 - 添加尾部斜杠以解决上一个问题时,我得到404错误。我是PHP的新手,不确定我应该如何链接文件。我认为这与链接网站上所有其他html文件是一样的,显然不是。

I have all the index.html, html_form_send.php, and contactthanks.php all in the same top (1st) level directory, with 2nd level CSS, JS, Font, and Img folders

我将所有index.html,html_form_send.php和contactthanks.php都放在同一个顶级(第一级)目录中,包含第二级CSS,JS,Font和Img文件夹

All relavent code is below

所有相关代码如下

HTML

HTML

    <div class="8u 12u$(small)">
<form name="htmlform" method="post" action="html_form_send.php">
<div class="row uniform 50%">
<div class="6u 12u$(xsmall)"><input type="text" name="name" id="name" placeholder="Name" /></div>
<div class="6u$ 12u$(xsmall)"><input type="email" name="email" id="email" placeholder="Email" /></div>
<div class="12u$"><textarea name="message" id="message" placeholder="Message" rows="4"></textarea></div>
</div>
<ul class="actions">
<li><input type="submit" value="Send Message" /></li>
</ul>
</div>
</form>

PHP from html_form_send.php

来自html_form_send.php的PHP

<?php

$EmailFrom = "Michael.kalmykov.88@gmail.com";
$EmailTo = "Michael@kovcreation.com";
$Subject = "from fictive site";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));

// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php/\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

PHP from contactthanks.php

PHP来自contactthanks.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">

<head>
    <title>work already!</title>

    <link rel="stylesheet" type="text/css" href="style.css" />
</head>

<body>

    <div id="page-wrap">


        <br /><br />


    <h1>Your message has been sent!</h1><br />

    <p><a href="index.html">Back to Site</a></p>

</div>

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-68528-29";
urchinTracker();
</script>

I'm sure its something stupid and simple but I've been searching forums for hours now and can't seem to find the issue.

我确定它有些愚蠢和简单,但我现在一直在搜索论坛几个小时,似乎无法找到问题。

Thanks for any help with this.

感谢您对此的任何帮助。

1 个解决方案

#1


0

When redirecting, headers are better than html meta tags. Keep in mind that you can use an header only when you haven't printed anything.

重定向时,标头优于html元标记。请记住,只有在没有打印任何内容时才能使用标题。

Here how you can use headers:

在这里你如何使用标题:

header("location: ./yourfile.html");

header(“location:./ yourfile.html”);

Also, some tips to create a correct file path

此外,一些提示,以创建正确的文件路径

To redirect to a file in the same folder use "./filename.php"

要重定向到同一文件夹中的文件,请使用“./filename.php”

To redirect to a file that is in an external directory you can use "../" to exit 1 dir. for example if my file is inside "/hello/file.php" and I wanna redirect to "/index.php" my path will be "../index.php"

要重定向到外部目录中的文件,可以使用“../”退出1目录。例如,如果我的文件在“/hello/file.php”内,我想重定向到“/index.php”,我的路径将是“../index.php”

更多相关文章

  1. html页面输出pdf格式文件(一步步很详细)
  2. commons-fileupload文件上传、下载
  3. Eclipse中以html格式高亮显示velocity文件
  4. 将PHP代码添加到.html文件
  5. 性能权衡 - CSS效率,CSS文件大小,HTML文件大小
  6. 上传文件,那么form中用来接收文件的数据成员是什么类型?
  7. 请问json文件在html head中以script的形式导入了,怎样读取这个jso
  8. 帮助相对路径链接到本地​​文件
  9. html文件上传到vss上面后文件大小改变

随机推荐

  1. Android 自定义Camera 随笔
  2. android LinearLayout设置selector不起作
  3. Android getWindow().setFlags方法与SD卡
  4. Android调用拨号程序,短信发送
  5. Android NDK各版本下载
  6. android源码分享
  7. android 屏幕自适应
  8. FFmpeg交叉编译
  9. android基础(对话框风格Activity实现)
  10. android LinearLayout 垂直滚动