我在本页面上使用了我的老师提供的PHP脚本; 但由于我在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><TITLE>www.lucsenden.nl - Voor al uw videoproducties.</TITLE>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<META name=robots content=index,follow>
<META name=keywords content=" ">
<META name=description content=" ">
<META content=0 http-equiv=Expires><LINK rel=stylesheet type=text/css href="style.css" media=screen>
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<!--[if IE]>
<link type="text/css" href="css/ie.css" rel="stylesheet" media="screen" />
<![endif]-->
<!--[if IE 6]>
<script type="text/javascript" src="js/pngfix.js"></script>
<script type="text/javascript">
DD_belatedPNG.fix('img,#logo');
</script>
<![endif]-->
<LINK rel=stylesheet type=text/css href="css/ie.css" media=screen>
</HEAD>
<BODY>
<DIV class=top-bar-wrap> </DIV>
<DIV class=main-bg>
<DIV id=sub-page class=main-wrap>
<DIV id=header class=mod-con>
<H1 id=logo><A href="/#"><IMG alt="" src="/image/luc.png"></A></H1>
<UL id=main-menu>
<LI><A href="/index.html"><STRONG>Home</STRONG></A><A class=cur href="/about.html"><STRONG>Over mij</STRONG></A> </LI>
<LI><A href="/diensten.html"><STRONG>Diensten</STRONG></A> </LI>
<LI><A href="/portfolio.html"><STRONG>Portfolio</STRONG></A> </LI>
<LI><A href="/referenties.html"><STRONG>Referenties</STRONG></A> </LI>
<LI><A href="/contact.html"><STRONG>Contact</STRONG></A> </LI></UL></DIV>
<DIV id=main class=mod-con>
<DIV class="container clearfix">
<DIV style="WIDTH: 861px;HEIGHT: 1006px" id=about-page class=main-con>
<DIV class=title-nav>
<H2>Contact</H2></DIV>
<DIV class=content>
<P>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam et risus non arcu porttitor feugi at in at neque. In hac habitasse platea dictumst. Proin pretium neque at turpis fermentum de aliquet. Ut risus nisi, scelerisque in convallis et, volutpat malesuada elit. Ut nulla libero, condi entum eget scelerisque eget, blandit sit amet metus. Suspendisse potenti. Nulla luctus temus augue dictum cursus. Curabitur non risus dui. In sit amet tellus in lacus fringilla condimentuma t sit amet libero. Fusce purus ligula, hendrerit ut vulputate eget, vestibulum non diam. Vestib ulum facilisis, leo id volutpat vestibulum, eros ligula ornare urna, pellentesque laoreet magna purus ac metus. Nulla facilisi.</P>
<?php
echo '';
if(isset($_POST['submit'])) {
$subject = $_POST['naam'].' stuurde een mail via PHP!';
$email = $_POST[''];
$bericht = wordwrap($_POST['bericht'], 70);
$versturen_gelukt = mail($email, $subject, $bericht);
if($versturen_gelukt) {
echo ' <p>De email is verstuurd! <a href="'.$_SERVER['PHP_SELF'].'">Nog een mail sturen</a>.</p>'."\r\n";
} else {
echo ' <p>Er is iets mis gegaan, <a href="'.$_SERVER['PHP_SELF'].'">probeer het opnieuw</a>.</p>'."\r\n";
}
} else {
echo '
<form action="'.$_SERVER['PHP_SELF'].'" method="POST" type="text/plain">
<label for="name">Naam</label>
<input type="naam" name="naam" id="naam" />
<label for="email">Email</label>
<input type="email" name="email" id="email" />
<label for="bericht">Bericht</label>
<textarea name="bericht" id="bericht"></textarea>
<label for="submit"></label>
<input type="submit" name="submit" id="submit" value="Stuur bericht!" />
</form>
';
}
echo ' ';
?>
</DIV></DIV></DIV></DIV></DIV></DIV>
<DIV class=siteintro-wrap> </DIV>
<DIV class=footer-wrap>
<DIV id=footer class=mod-con>
<DIV class=copyright>© 2012 Copyright All Rights Reserved.
</DIV>
<DIV class=hovergallery>
<a href="http://facebook.com/lucsenden"><img src="http://i44.tinypic.com/10p9g5i.png" /></a>
<a href="http://youtube.com/luckske112"><img src="http://i44.tinypic.com/34rwqdv.png" /></a>
<a href="http://twitter.com/lucsenden"><img src="http://i42.tinypic.com/xfst8g.png" /></a>
</DIV>
</DIV></DIV></BODY></html>
';
?>
答案 0 :(得分:3)
你正在写
$email = $_POST['email@hotmail.com'];
这基本上意味着$email
变量(收件人)被设置为名为email@hotmail.com
的字段包含的任何内容。对于字段名称,这将是一个非常奇怪的名称,幸运的是,您没有这样的字段名称。
相反,你应该写
$email = "email@hotmail.com";
该电子邮件地址将成为您电子邮件的收件人。