これらのフォームを PHP で作成しましたが、必須フィールドがなく、名前、電話番号、電子メールを必須にしたいと考えています。どうすればいいですか?
コードは次のとおりです。
<?php
$company = $_POST['company'];
$contact = $_POST['name'];
$tel = $_POST['phone'];
$email = $_POST['email'];
$comments = $_POST['message'];
$contact_type = $_POST['contact_type'];
if ($contact_type=="1")
{
$form_desc = "Contact Request Submitted";
$to_email = "mail@burlingtongroup.net, ross.crawford@burlingtongroup.net, adam.ninnis@burlingtongroup.net";
}
else if ($contact_type=="2" || $contact_type=="3")
{
$form_desc = "Call-back Request Submitted";
$to_email = "mail@burlingtongroup.net, ross.crawford@burlingtongroup.net, adam.ninnis@burlingtongroup.net";
}
else if ($contact_type=="4")
{
$form_desc = "Training Seminar Registration";
$to_email = "adam.wonnacott@burlingtongroup.com";
}
$source_page = $_SERVER['HTTP_REFERER'];
//If no errors registred, print the success message
if(isset($_POST['Submit']))
{
global $mailer;
if($contact_type=="3")
{
$content = $form_desc.", \n\n".
"Company: ".$company."\n".
"Contact: ".$contact."\n".
"Tel: ".$tel."\n".
"Email: ".$email."\n".
"Message: ".$comments."\n";
}
else if($contact_type=="4")
{
$content = $form_desc.", \n\n".
"Company: ".$company."\n".
"Contact: ".$contact."\n".
"Email: ".$email."\n";
//echo $content;
//exit;
}
else
{
$content = $form_desc.", \n\n".
"Company: ".$company."\n".
"Contact: ".$contact."\n".
"Tel: ".$tel."\n".
"Email: ".$email."\n".
"Message: ".$comments."\n";
}
mail($to_email, $form_desc.":".$company, $content, "From: ".$email );
header('Location: '.$source_page.'?sent=1');
}
?>