我正在开发我的第二个网站,在创建这个网站的过程中,我第一次在StackOverflow上的人们提供了很棒的帮助.
我可以浏览并找到几乎我不想知道的任何东西.
99%的问题,我已经解决了我在这里读过的答案.
首先,非常感谢你们!
这是我第一次发帖,因为我无法找到代码的具体答案.
有人在这里有同样的问题,但当我看他们的代码我只是迷路了.
我现在知道html了.这是我无能为力的PHP.
我不是在寻找一些奇特的东西,我只是想创建一个简单的联系表格.
所以这是我的问题和代码,我希望你们中的一些人能够帮助我.
我使用了一个来自youtube教程的PHP代码并且它是deadeasy(如前所述:第一次PHP)但我无法让它工作.虽然我做的一切与剪辑中的男人一样.他表明他正在工作,所以我非常好奇,我的方式不是吗?
我的表单没有“发送”,点击提交按钮后我没有收到“谢谢”行.
这是html:
<form method="post" action="contactform" name="contactform" id="contactform">
<ol>
<li>
<label for="voornaam">Voornaam</label>
<input type="text" name="voornaam" />
</li>
<li>
<label for="achternaam">Achternaam</label>
<input type="text" name="achternaam" />
</li>
<li>
<label for="telefoon">Telefoon Nummer</label>
<input type="text" name="telefoon" />
</li>
<li>
<label for="email">E-mail Adres</label>
<input type="text" name="email" />
</li>
<li>
<label for="bericht">Type hier je bericht</label>
<textarea name="bericht"></textarea>
</li>
<li>
<input name="submit" type="submit" value="submit" />
<input name="reset" type="reset" value="reset" />
</li>
</ol>
</form>
和PHP:
<?php
$voornaam = $_POST ['voornaam'];
$achternaam = $_POST ['achternaam'];
$telefoon = $_POST ['telefoon'];
$email = $_POST ['email'];
$bericht = $_POST ['bericht'];
$to = "felicevancuyk@gmail.com";
$subject = "dkl groep bericht";
mail ($to, $subject, $bericht, "From " . $voornaam . $achternaam . $telefoon};
echo "Bedankt. We nemen zo snel mogelijk contact met u op.";
?>
最佳答案 可能是您的操作设置不正确:
<form method="post" action="contactform" name="contactform" id="contactform">
此操作标记是表单发送到的URL.在您给出的上述示例中,它似乎不是文件名.你希望它是这样的:
<form method="post" action="http://mysite.com/process-form.php" name="contactform" id="contactform">
另请注意,在您的示例PHP代码中,您通过电子邮件发送对表单的响应而不清除这些响应.如果您不先清理数据,有人可能会向您的服务器发送恶意代码.
就像是:
$cleaned_voornaam = preg_replace("/[^ 0-9a-zA-Z]/", "_", $_POST['voornaam']);
祝好运!