Php 发送邮件并重定向到其他网站
我需要发送一封电子邮件,然后重定向到另一个网站。 我对php不太熟悉,我无法让它工作。 有人能帮忙吗 代码:Php 发送邮件并重定向到其他网站,php,email,redirect,Php,Email,Redirect,我需要发送一封电子邮件,然后重定向到另一个网站。 我对php不太熟悉,我无法让它工作。 有人能帮忙吗 代码: 无论您想重定向到其他网站,请添加以下内容: header("Location: http://example.com"); exit; 您必须使用标题函数重定向 header('Location: http://www.example.com/'); 请注意,在使用此选项之前,不得出现任何类型的输出 if (mail($email,"Bestelling",$message,$hea
无论您想重定向到其他网站,请添加以下内容:
header("Location: http://example.com");
exit;
您必须使用
标题
函数重定向
header('Location: http://www.example.com/');
请注意,在使用此选项之前,不得出现任何类型的输出
if (mail($email,"Bestelling",$message,$headers))
{
header("Location: http://example.com");
exit;
}
else
{
echo "We kunnen geen mail sturen naar je opgegeven mailadres.";
echo "Ben je zeker dat het correct is?";
}
把这个换成这个
if (!mail($email,"Bestelling",$message,$headers))
{ echo "We kunnen geen mail sturen naar je opgegeven mailadres.";
echo "Ben je zeker dat het correct is?";
}
else
{
//--- this section will run when mail is sent.
header('location:your_desired_page.php')
}
什么特别不起作用?您是否正在访问这些
echo
语句?如果是的话,你要到达哪一个?用于重定向。可能标题(“刷新:5;url=http://wherever.com" );
@Lino Meert
-当您提出问题时,为了让我们更好地理解,您需要将您的信息完全用英语发布。因此,当有人发布答案或评论时,您可以使用您喜欢的语言进行修改。这只是一个很好的实践,并排除了困惑。只是说。@Lino Meert
-补充一句,将它与之相关的表单包含进来也会对您有所帮助。从翻译完上述文字后我可以看出,你只是在检查是否有人没有输入电子邮件。您需要向它添加一个函数。您的else{}
为空,需要知道您是否有(可能)没有向我们显示的其他代码。下面给出的所有答案都是有效的。您需要进一步研究表单和PHP。我们无法为您编写代码,但可以帮助您编写一些功能性的代码。输出很好,我没有提及它。我尝试了这个,但没有起作用。@LinoMeert它没有起作用,因为您为我们提供的代码是(!mail…
如果没有(条件),则转换为然后不要处理。没有if/success as iselse{mail($email,…;)}
将它发送到某个地方。仅供参考!=否定。然后我会向您推荐一个非常好用的PHPMailer库。您可以在我的个人博客www.computersneaker.com上阅读关于PHPMailer的文章
if (!mail($email,"Bestelling",$message,$headers))
{ echo "We kunnen geen mail sturen naar je opgegeven mailadres.";
echo "Ben je zeker dat het correct is?";
}
else
{
}
if (!mail($email,"Bestelling",$message,$headers))
{ echo "We kunnen geen mail sturen naar je opgegeven mailadres.";
echo "Ben je zeker dat het correct is?";
}
else
{
//--- this section will run when mail is sent.
header('location:your_desired_page.php')
}