提交表单时,css丢失

时间:2015-07-27 09:31:31

标签: html css forms loading contact

表格

<form method="post" action="php/contactengine.php">
<ul>
  <li><label for="Name">Name:</label></li>
  <li><input type="text" name="Name" id="Name" /></li>
</ul>
<ul id="Surname">
  <li><label for="Surname">Surname:</label></li>
  <li><input type="text" name="Surname" id="Surname" /></li>
</ul>
<ul>
  <li><label for="Town">Town:</label></li>
  <li><input type="text" name="Town" id="Town" /></li>
</ul>
<ul>
  <li><label for="Tel">Mob/Tel:</label></li>
  <li><input type="text" name="Tel" id="Tel" /></li>
</ul>
<ul>
  <li><label for="Email">Email:</label></li>
  <li><input type="text" name="Email" id="Email" /></li>
</ul>
<ul>
  <li><label for="Message">Message:</label><br /></li>
  <li><textarea name="Message" rows="30" cols="20" id="Message"></textarea></li>
</ul>
<input type="submit" name="submit" value="Submit" class="submit-button" />
<input type="reset" name="reset" value="Clear" class="reset-button" /></form>

引擎

 <?php

$EmailFrom = "enquiry@madisonjacob.co.uk";
$EmailTo = "james@madisonjacob.co.uk";
$Subject = "Website communication - MadisonJacob";
$Name = Trim(stripslashes($_POST['Name']));
$Surname = Trim(stripslashes($_POST['Surame']));
$Town = Trim(stripslashes($_POST['Town']));
$Tel = Trim(stripslashes($_POST['Tel']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));

// validation

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

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

// send email
if(isset($_POST['Surame']) && $_POST['Surname'] == '') {
  $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
}

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

... 有联系表单的问题只是在没有任何css显示的情况下进入错误页面。想想我已经在某处使用了一些建议(我的错,我确定)。 我是否必须使用计数器强制刷新初始加载,以便它不会继续重新加载(如果是这样,最好如何做到这一点)? 如果仅仅是因为我没有使用上面的最佳代码,那么请纠正我,谢谢。 姓氏是隐藏字段(由css隐藏)以使用表单停止机器人。 所有人都非常感激。

1 个答案:

答案 0 :(得分:-1)

您能否发布完整的代码?休息我觉得你必须使用

document.location.href ='contact-thanks.php';

用于重定向。