여러 가지 방법으로 검색하고 시도했지만 아무 것도 계획대로 작동하지 않습니다. 그 요즘 필요하지만 그건 내가 묻고있는 이유의 경우 나는 문의 양식을 설정하고 양식 작업으로htmlspecialchars를 사용하여 php mail() 함수에 문제가 발생하면 페이지가로드 될 때마다 메일이 전송됩니다.
<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>
를 사용하는 것을 시도하고, 확실하지, 나는 어떤 주사가 일어나고 싶지 않아요. 양식은 상자에 정보가 있는지 또는 오류가 있는지 여부와 상관없이 내가 페이지를로드 할 때마다 메일을 보내는 것을 제외하고는 메일을 보내고 싶은 방식으로 작동합니다. 여기에 도움이 필요한 두 가지 사항이 있습니다.
- 가 제대로 < 기간에 감사의 메시지를 표시> 형태의 바닥, 모달 팝업 또는 부트 스트랩 경고 메시지에서 요소입니다.
submit버튼을 클릭하면이 한 페이지 우편물이 작동하고 POST에서만 발행인 확인 기능이 필요합니다.
아래에는 현재 가지고있는 모든 PHP 및 html 양식 코드가 들어 있습니다. 진보 된 감사합니다. 난 당신이 모든 페이지로드에있는 파일의 끝에서 mail($to,$subject,$message,$headers);
를 호출 보는 것과
<?php
// define variables and set to empty values
$nameErr = $emailErr = $ethaddressErr = $txhashErr = $messagesErr = "";
$name = $email = $ethaddress = $txhash = $messages = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$nameErr = "Name is required";
} else {
$name = test_input($_POST["name"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$nameErr = "Only letters and white space allowed";
}
}
if (empty($_POST["email"])) {
$emailErr = "Valid Email is required";
} else {
$email = test_input($_POST["email"]);
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
}
}
if (empty($_POST["ethaddress"])) {
$ethaddress = "";
} else {
$ethaddress = test_input($_POST["ethaddress"]);
if (!preg_match("/^(0x)?[0-9a-f]{40}$/i",$ethaddress)) {
$ethaddressErr = "Invalid ETH Address Format";
}
}
if (empty($_POST["txhash"])) {
$txhash = "";
} else {
$txhash = test_input($_POST["txhash"]);
if (!preg_match("/^(0x)?[0-9a-f]{64}$/i",$txhash)) {
$txhashErr = "Invalid Ethereum Transaction Hash Format";
}
}
if (empty($_POST["messages"])) {
$messages = "";
} else {
$messages = test_input($_POST["messages"]);
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<form id="my-form" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div class="form-group has-feedback">
<label for="name" class="control-label sr-only">Name</label>
<input type="text" name="name" value="<?php echo $name;?>" required placeholder="Please Enter Your Name" autofocus class="form-control" id="firstname" /><i aria-hidden="true" class="form-control-feedback fa fa-user"></i></div>
<span class="error"><?php echo $nameErr;?></span>
<div class="form-group has-feedback">
<label for="ethaddress" class="control-label sr-only">ETH Address</label>
<input type="text" name="ethaddress" value="<?php echo $ethaddress;?>" placeholder="ERC20 Compliant ETH Address" class="form-control" id="lastname" /><i aria-hidden="true" class="form-control-feedback fa fa-link"></i></div>
<span class="error"><?php echo $ethaddressErr;?></span>
<div class="form-group has-feedback">
<label for="txhash" class="control-label sr-only">TxHash</label>
<input type="text" name="txhash" value="<?php echo $txhash;?>" placeholder="Transaction Hash of Purchase, if applicable" class="form-control" id="phonenumber" /><i aria-hidden="true" class="form-control-feedback fa fa-hashtag"></i></div>
<span class="error"><?php echo $txhashErr;?></span>
<div class="form-group has-feedback">
<label for="email" class="control-label sr-only">Email Address</label>
<input type="text" name="email" required value="<?php echo $email;?>" placeholder="Please Enter Valid Email Address" class="form-control" id="email" /><i aria-hidden="true" class="form-control-feedback fa fa-envelope"></i></div>
<span class="error"><?php echo $emailErr;?></span>
<div class="form-group has-feedback">
<label for="messages" class="control-label sr-only">Additional comments for the team</label>
<textarea rows="8" name="messages" placeholder="Additional Comments for the Team" required class="form-control"><?php echo $messages;?></textarea><i aria-hidden="true" class="form-control-feedback fa fa-pencil"></i></div>
<span class="error"><?php echo $messagesErr;?></span>
<button class="btn btn-default btn-lg" type="submit" name="submit" id="form-btn">SEND </button>
</form>
<?php
$to = "[email protected]";
$subject = "BioPayCoin Contact Form Submission";
$name = $_POST["name"];
$messages = $_POST["messages"];
$email = $_POST["email"];
$ethaddress = $_POST["ethaddress"];
$txhash = $_POST["txhash"];
$message = $name . " sent you a message" . "\r\n" . $email . "\r\n" . $ethaddress . "\r\n" . $txhash . "\r\n" . $messages;
$headers = "From: [email protected]" . "\r\n" .
"CC: [email protected]";
mail($to,$subject,$message,$headers);
?>
"action"속성을 제거 할 수 있습니다. – Pauloscorps