-1
私は、Webフォーム経由で電子メールを送信しようとしていますが、私は、この未定義のインデックスエラー以下お知らせ:未定義のインデックス:エラー
Undefined index: email in C.....
Undefined index: phone in C....,
Undefined index: name in C......
Undefined index: message in C.....
は私のPHPコードが
<?php
session_start();
//error_reporting(0);
if(isset($_POST['submitted'])) {
{
$sendto = "[email protected]"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$name = $_POST['name'];
$phone = $_POST['phone'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $name . " " . " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $name . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $sendto;
$msg = "<html><body style='font-family:Arial,sans-serif;'>";
$msg .= "<h2 style='font-weight:bold;border-bottom:1px dotted #ccc;'>New User Feedback</h2>\r\n";
$msg .= "<p><strong>Sent by:</strong> ".$from."</p>\r\n";
$msg .= "<p><strong>Message:</strong> ".$message."</p>\r\n";
$msg .= "<p><strong>Name:</strong> ".$name."</p>\r\n";
$msg .= "<p><strong>Phone:</strong> ".$phone."</p>\r\n";
$msg .= "</body></html>";
if(mail($sendto, $subject, $msg, $headers)) {
echo '<center><p style="color:green">Mail Sent. Thank you, we will contact you shortly.</p></center>';
} else {
echo '<center><p style="color:red">Mail not Sent. Try Again.</p></center>';
}
}
}
?>
が、ときに私が提出され得ますそれは以下のこれらのエラーをスローし 、フォームは
<form name="submitted"action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="POST">
<div class="styled-input wow slideInUp animated animated" data-wow-delay=".5s">
<input type="text" id="name" required />
<label>Name</label>
<span></span>
</div>
<div class="styled-input wow slideInUp animated animated" data-wow-delay=".5s">
<input type="email" id="email"required />
<label>Email</label>
<span></span>
</div>
<div class="styled-input wow slideInUp animated animated" data-wow-delay=".5s">
<input type="tel" id="phone"required />
<label>Phone</label>
<span></span>
</div>
<div class="styled-input wide wow slideInUp animated animated" data-wow-delay=".5s">
<textarea id="message" required></textarea>
<label>Message</label>
<span></span>
</div>
<div class="send wow shake animated animated" data-wow-delay=".5s">
<input name="submitted" type="submit" value="Send" >
</div>
</form>
が、私はこのエラーを修正するにはどうすればよいというのが私のフォームですか?これに
<input type="text" id="name" required />
:
<input type="text" id="name" name="name" required />
name
属性を持たないすべての<input>
タグ(および<textarea>
)を繰り返し すべてのヘルプはよくこの
問題を解決しました – youngdero