1

「名前」フィールドのある連絡フォームがあります。

<form class="form-inline" role="form" method="post" action="contactengine.php" id="commentForm" style="display:table; margin:20px auto">

 <div class="well">

 <div class="form-group">
 <label class="sr-only" for="Email">Email address</label>
 <input type="email" name="Email" id="Email" class="form-control required" placeholder="Enter email address" autofocus>
 </div>

 <div class="form-group">
 <label class="sr-only" for="Name">Name</label>
 <input type="text" name="Name" id="Name" class="form-control required" placeholder="Last, First" >
 </div>

 <div class="form-group">
 <label class="sr-only" for="Rating">Rating</label>
 <input class="form-control" placeholder="rating" type="number" name = "Rating" id = "Rating" min="1200" max="2500" value="2000">
 </div> 

 <div class="form-group">
 <label class="sr-only" for="City">Location</label>
 <input type="text" class="form-control required" placeholder="City, Country" name="City" id="City" pattern=".{2,23}" />
 </div> 

 </div>

<div class="well">
<div class="col-md-12 col-md-offset-0">

<textarea placeholder = "Optionally, list some chess background info here about your abilities and style. Include experience, books read, goals, strengths and weaknesses, even a pgn file." name="Message" id="Message" rows="4" class="required" style="width:100%"></textarea>

</div>
</div>

<div class="col-md-6 col-md-offset-3">

<div style="margin: 0 auto; display:table;">

<button type="reset" name="submit" class="btn btn-warning bold" style="float:left; font-size:18px; margin:20px 40px">Reset</button>

<button type="submit" name="submit" class="btn btn-success bold" style="float:right; font-size:18px; margin:20px 40px">Submit</button>

</div>
</div>

</form> 

そして、それを処理するためのphpスクリプトがあります:

<?php

// CHANGE THE VARIABLES BELOW


$EmailFrom = "joeblow@gmail.com";
$EmailTo = "joeblow@gmail.com";
$Subject = "Contact Form Submission";

$Name = Trim(stripslashes($_POST['Name'])); 
$Rating = Trim(stripslashes($_POST['Rating'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$City = Trim(stripslashes($_POST['City'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// prepare email body text
$Body = "";

$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";

$Body .= "Rating: ";
$Body .= $Rating;
$Body .= "\n";

$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";

$Body .= "Location: ";
$Body .= $City;
$Body .= "\n";

$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
// CHANGE THE URL BELOW TO YOUR "THANK YOU" PAGE
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">";
}
?>

問題は、名前を送信しないことを除いて、スクリプトが機能することです。「名前:」だけで、フォームから名前が取得されません。それの何が問題なのですか?

4

1 に答える 1