私はhtmlページからPHPにデータを持ち込むことができませんでした。私は一日中それをテストしていましたが、私はこの問題に固執しています。手伝っていただけませんか?どうもありがとうございます。以下は私のコード....htmlのデータがphpファイルに表示されず空のメールとして送信される
service.htmlのある
<div class="accordion-inner">
<div class="status alert alert-success" style="display: none"></div>
<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="requestquote.php" role="form">
<div class="row-fluid">
<div class="span5" style="text-align: left;">
<label>FULL NAME</label>
<input type="text" name="fname" id="fname" class="input-block-level" required="required" placeholder="Your Full Name" tabindex="1">
<label>COMPANY (OPTIONAL)</label>
<input type="text" name="cname" id="cname" class="input-block-level" placeholder="Your Company Name" tabindex="2">
<label>EMAIL </label>
<input type="text" name="email" id="email" class="input-block-level" required="required" placeholder="Your Email Address" tabindex="3">
<label>PHONE</label>
<input type="text" name="phone" id="phone" class="input-block-level" required="required" placeholder="Your Phone" tabindex="4">
</div>
<div class="span7" style="text-align: left;">
<label>SOLUTIONS</label>
<select name="category" id="category">
<option value="">Please Select…</option>
<option value="Web Design and Development">Web Design and Development</option>
<option value="Mobile Application Development">Mobile Application Development</option>
<option value="Networking Services & Consultancy">Networking Services & Consultancy</option>
<option value="Hotel Management Solution ">Hotel Management Solution </option>
<option value="IT Help Desk Service ">IT Help Desk Service </option>
</select>
<label>YOUR IDEAS (OR) MESSAGE </label>
<textarea name="message1" id="message1" required="required" class="input-block-level1" rows="10" tabindex="5"></textarea>
</div>
</div>
<input type="submit" name="sendmsg" class="btn btn-primary btn-large pull-right" value="Send Message">
</form>
</div>
</div>
requestquote.php
<?php
header('Content-type: application/json');
$status = array(
'type'=>'success',
'message'=>'Thank you for contacting us!, '
);
$fname = @trim(stripslashes($_POST['fname']));
$cname = @trim(stripslashes($_POST['cname']));
$email = @trim(stripslashes($_POST['email']));
$phone = @trim(stripslashes($_POST['phone']));
$category = @trim(stripslashes($_POST['category']));
$message1 = @trim(stripslashes($_POST['message1']));
$email_from = $email;
$email_to = "[email protected]";
$from = "[email protected]";
$headers = "From:" . $from;
$Body = 'First Name: ' . $fname . "\n \n " .'Company Name: ' . $cname . "\n\n" . 'Email: ' . $email . "\n\n" . 'Phone: ' . $phone . "\n\n" . 'category: ' . $category . "\n\n" . 'Message: ' . $message1;
$success = @mail($email_to,"Request a free quotation", $Body, $headers);
$thankyou = "Thank you for contacting us. We will be in touch with you shortly.";
@mail($email_from," Request a free quotation ", $thankyou, $headers);
if($success == true){
echo json_encode($status);
die;
} else {
echo json_encode(" Failed ");
}
>
https://stackoverflow.com/questions/29815710/why-is-phps-mail-function-successfully-sending-mail-but-with-空白フィールド – claudio
これは以下のようなものです:header( 'Content-type:application/json'); – halojoy
あなたはエラーを甘やかすべきではありません:@mail($ email_fromはメールのようにベターです($ email_from – halojoy