0

我已经设法在提交工作时使用重定向功能制作名称/电子邮件表单。现在唯一的问题是,当重定向页面加载时,我会在其顶部获得表单输入(姓名和电子邮件)。

有人知道我在哪里不及格了吗?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
 function submitForm() {
      var form = document.forms[0];
      if (form.name.value == '') { alert("Name?"); return; }
      if (form.email.value == '') { alert("Email?"); return; }

      apos = form.email.value.indexOf("@");
      dotpos = form.email.value.lastIndexOf(".");
      if (apos < 1 || dotpos - apos < 2) { alert("Correct email?"); return; }

      form.submit();
  }
</script>
<script src="fancybox/jquery.fancybox-1.3.1.pack.js" type="text/javascript"></script>
<link rel="stylesheet" href="fancybox/jquery.fancybox-1.3.1.css" type="text/css" media="screen"/>

<script type="text/javascript">
function PopIt() { 
    $("a#trigger").trigger('click');
    window.onbeforeunload = UnPopIt;
    return "Dont go."; 
}

function UnPopIt()  { /* nothing to return */ } 

$(document).ready(function() {
    window.onbeforeunload = PopIt;

    $("a#trigger").fancybox({
        'hideOnContentClick': false,
        'showCloseButton': false
    });

    $("a[id!=trigger]").click(function(){ window.onbeforeunload = UnPopIt; });
});
</script>

</head>
<body>

<div style="display: none;">
<a id="trigger" href="#popup">&nbsp;</a>
<div id="popup">
<div style="background-color:#ff3300;">
<form method="post" action="page2.php" name="popups" id="popups">
        <fieldset>
        <label for=name><span class="required">*</span> Name</label>
        <br />
        <input name="name" type="text" id="name" size="30" value="" /> 
        <br />
        <label for=email><span class="required">*</span> Email</label>
        <br />
        <input name="email" type="text" id="email" size="30" value="" />
        <br />
        <input type="button" value="Submit" class="btn" onclick="submitForm();">            
        </fieldset>  
        <br />
</form>
</div>        
</div>
</div>

<div id="content">Fa la la la la</div>
</div>
</body>
</html>

当访问者输入数据时(在弹出窗口中,退出时触发),点击提交按钮后,表单重定向到这里;

<? 
if($_POST['name']!="" and $_POST['email']!=""){

$headers    = "From: Acme";
$message    = 
strtoupper($_POST['name'])."
".strtoupper($_POST['email'])."
";
echo str_replace("\n","<br />", $message);
$headers2    = "From: Acme <ceo@acme.com>\nContent-Type: text/plain; charset=UTF-8;             format=flowed\nMIME-Version: 1.0\nContent-Transfer-Encoding: 8bit\nX-Mailer: PHP\n";
$message2    = "
Hello ".($_POST['name'])."   

";

mail("ceo@acme.com", "Freebies", $message, $headers);        
mail("$_POST[email]", "Gesundheit!", $message2, $headers2);

$myFile = "free.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = "$_POST[name]*$_POST[email]*".$_SERVER['REMOTE_ADDR']."*".date("d-m-Y     H:i")."
";
fwrite($fh, $stringData);
fclose($fh);

}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
setTimeout(function(){
$("div#md").fadeIn("slow", function () {
});

}, 1000);
});
</script>
</head>
<body>
<div id="top"><a href="index.html"><img src="top.png" /></a></div>
<div id="wrapper" style="height:900px;">
<div id="content">Whoo-eee</div>
</div>
</body>
</html>

但我看不到此 page2.php 顶部显示的表单信息(姓名和电子邮件)如何或为何存在...

4

2 回答 2

0

你有这条线

  echo str_replace("\n","<br />", $message);

靠近第 2 页的顶部,因此您正在回显由姓名和电子邮件组成的消息

于 2012-07-27T08:58:42.450 回答
0
echo str_replace("\n","<br />", $message);

在 page2 上注释掉这一行

于 2012-07-27T09:00:54.793 回答