2
저는 PHP에 관해서는 총 n00b입니다. (틀림없이 웹 개발은 일반적으로 /)입니다.하지만 많은 코드 예제를 살펴 보았습니다. 아웃. 기본적으로 일어나는 일은 contact.php 파일이 내 컴퓨터로 다운로드되는 것입니다. 우. 또한이 클라이언트는 필드 유효성 검사를 요청하지 않았으므로 그 이유는 없습니다. 도움!!이 PHP 문의 양식은 왜 contact.php를 다운로드합니까?
을 heres 내, HTML
<form action="contact.php" method="post">
<fieldset>
<legend><strong>Get A Quote!</strong>
</legend>
Call me at 555-555-5555, or email me at <a href="">[email protected]</a>, or use the form below.<br /><br />
<div class="clearfix">
<div class="input">
<input style="width:370px; height:35px; font-size:14px;" value="Name" name="name" size="50" type="text">
</div>
</div><!-- /clearfix -->
<div class="clearfix">
<div class="input">
<input style="width:370px; height:35px; font-size:14px;" value="Email" name="email" size="50" type="text">
</div>
</div><!-- /clearfix -->
<div class="clearfix">
<div class="input">
<input style="width:370px; height:35px; font-size:14px;" value="Phone" name="phone" size="50" type="text">
</div>
</div><!-- /clearfix -->
<div class="clearfix">
<div class="input">
<textarea style="width:370px; height:55px; font-size:14px;" name="message" size="50" type="text">Message</textarea>
</div>
</div><!-- /clearfix -->
</fieldset>
<button type="submit" name="saveForm" style="background-image: url(static/img/btn-submit.png); width:150px; height:37px;"></button>
</form>
과 PHP-
<?php
if(isset($_POST['saveForm'])) {
$to = "[email protected]";
$subject = "Inquiry from website";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$phone_field = $_POST['phone'];
$message = $_POST['message'];
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
mail($to, $subject, $body);
} else {
echo "Sorry, something went wrong. Please email me at [email protected]";
}
?>
PHP가 실행되는 서버에 100 % PHP가 설치되어 있습니까? BTW : 그럼에도 불구하고 최소한 기본 수준에서 유효성을 검사해야합니다. 그렇지 않으면 스크립트를 사용하여 스팸을 보내는 다른 사람들이 스크립트를 (메일 헤더 삽입을 통해) 취약하게 만듭니다. – middus
[FastCGI] (http://www.fastcgi.com/drupal/) 또는 다른 방법을 사용하여 PHP를 실행하고 있습니까? PHP 컨텐트를 실행하기위한 서버 구성은 어떻게됩니까? – sarnold
덧붙여 말하자면, 여러분의 설정에서 ['suhosin.mail.protect'] (http://www.hardened-php.net/suhosin/configuration.html#suhosin.mail.protect)가 켜져 있었으면합니다. 이것은 사람들이 학대하기에 너무 쉬울 것입니다. – sarnold