-1
當我想到php和服務器端腳本時,我很新,所以請和我一起裸照。我有一個處理文件來驗證並通過我的網站發送一封聯繫表。就發送數據而言,一切都很好,但它不能正確處理任何錯誤。現在,如果必填字段爲空,則不應允許發送消息。但現在它仍然發送消息。我不知道如何解決這個問題,所以任何幫助表示讚賞。
這裏是我的PHP甚至有錯誤的PHP過程窗體
<?php
if(($_SERVER['REQUEST_METHOD'] =='POST') && (!empty ($_POST['action']))):
if (isset ($_POST['myname'])){$myname=$_POST['myname'];}
if (isset ($_POST['myphone'])){$myphone=$_POST['myphone'];}
if (isset ($_POST['myemail'])){$myemail=$_POST['myemail'];}
if (isset ($_POST['job'])){$job=$_POST['job'];}
if (isset ($_POST['comments'])){
$comments= filter_var($_POST['comments'], FILTER_SANITIZE_STRING);}
$formerrors = false;
if($myname === '') :
$err_myname = '<div class="error"> Sorry, your name is rquired</div>';
endif;
if($myphone === ''):
$err_myphone = '<div class="error"> Sorry, your phone number is rquired</div>';
endif;
if($myemail === ''):
$err_myemaile = '<div class="error"> Sorry, your email is rquired</div>';
endif;
if($job === ''):
$err_job = '<div class="error"> Sorry, your business is rquired</div>';
endif;
if (!($formerrors)) :
$to = "[email protected]";
$subject = " Request from $myname";
$message = "A new show and tell request from:\n
$myname \n
$myemail\n
$myphone\n
$job\n
$comments\n";
$replyto = "From: $myemail";
if(mail($to, $subject, $message)):
$msg ="Thanks for filling out our form";
else:
$msg = "There was a problem sending the message";
endif; //mail data
endif; //check errors
endif; //form submitted
?>
如果我需要張貼任何更多的信息,如實際的HTML,請讓我知道。
真棒感謝您的幫助 – mhartington