相同的文件只能在网站上使用?

时间:2013-02-06 11:42:51

标签: php forms

我被要求检查特定表格无效的原因。即使我对php一无所知,但我确实有一个工作表单,我在这个网站上测试过它并没有用。

我只是将我拥有的相同文件上传到两个不同的网站。但它在其中一个上做了很多工作。它不是不正确的代码。我不知道为什么它只适用于网站

编辑: 是的,我担心它们会被托管在其他地方,不同的服务器上

编辑:这是简化代码:

<!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" />
<title>FORM with validation examples</title>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script language=javascript>
function valida ()
{


if (document.example.name.value=="")
{
alert ('NAME field is empty!');
return false;
}


else if (document.example.email.value=="")
{
    alert ('EMAIL field is empty!');
    return false;
 }


else
{
return true;
}
}
</script>

</head>
<body>

<form name="example" id="example" action="submit-example.php" method="post" onsubmit="return valida();">    
<fieldset>

<label for="name">Name:</label>
<input type="text" name="name" id="name"/>

<label for="email">Email:</label>
<input type="text" name="email" id="email"/>    

<input type="submit" value="submit" />


</fieldset>
</form> 

</body>
</html>

<?php

$recebename = $_POST['name'];
$recebeemail = $_POST['email'];

$headers = "From: mail@gmail.com\r\n";
$headers .= "Content-type:text/html; charset=utf-8";

$para = "mail.ccs@gmail.com";

$mensagem   = "<h4>Name:</h4> ";
$mensagem  .= $recebename;

$mensagem  .= "<h4>Email:</h4> ";
$mensagem  .= $recebeemail;

$envia =  mail($para,"E-mail do Site",$mensagem,$headers);

$mensagem2  = "<p>Olá <strong>" . $recebename . "</strong>. Recebemos sua solicitação. Entraremos em contato em breve.</p>";

$mensagem2 .= "<p>Observação - Não é necessário responder esta mensagem.</p>";

$envia =  mail($recebeemail,"Sua mensagem foi recebida!",$mensagem2,$headers);

echo "Mensagens Recebidas com Sucesso!";
echo "<meta http-equiv='refresh' content='2;URL=http://www.google.com.br'>";
?>

2 个答案:

答案 0 :(得分:0)

检查文件中是否包含(例如include'head.php';)。如果是这样,您需要纠正错误。尝试添加完整的pathes(/folder1/subfolder/header.php)。

答案 1 :(得分:0)

我可以做几件事,首先想到的是:
两台服务器都支持PHP吗? 表单上的操作是否指向单独的文件? 如果是,那么命名是否正确?
表格上的动作是相对的还是绝对的路径? 表格上是否有验证需要单独的js文件?
表单上是否有ajax函数(或提交时)?
...
两台服务器都能发送电子邮件吗?