0
我有一個SVG動畫按鈕,提交按鈕的接觸形式。我發現與標籤標籤here一個整潔的解決方案,但可惜的標籤不允許它裏面的div。我搜索了網頁,並在按鈕標籤中找到了解決方案,該解決方案據稱與輸入提交功能相同。 不幸的是,我不知道爲什麼它不起作用。如果我使用標籤解決方案對其進行測試,它會起作用,並且表單被提交,所以PHP部分似乎沒問題。聯繫表SVG提交按鈕不工作(按鈕標籤,而不是輸入標籤)
HTML:
<form method="post" action="resources/js/send_email.php" id="contact_form">
<div class="row">
<div class="col span-2-of-4">
<input type="text" name="name" id="name" placeholder="Name" required>
<input type="email" name="email" id="email" placeholder="E-mail" required>
</div>
<div class="row">
<textarea name="message" placeholder="Message" id="message" required></textarea>
</div>
<div class="row" id="send-btn">
<div class="btn btn-main">
<button type="submit" class="send-btn">
<svg>
<rect fill="none" width="100%" height="100%"/>
</svg>
SEND
</button>
</div>
</div>
</div>
</form>
CSS:
.btn {
color: #c9234a;
cursor: pointer;
display: inline-block;
font-weight: 400;
line-height: 45px;
max-width: 240px;
position: relative;
text-decoration: none;
text-transform: uppercase;
vertical-align: middle;
width: 100%;
margin: 0 20px;
border-radius: 5px;
}
.btn p {
color: #373638;
}
.btn-main {
font-weight: 100;
}
.btn-main svg {
height: 45px;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
.btn-main rect {
fill: none;
stroke: #c9234a;
stroke-width: 2;
stroke-dasharray: 422, 0;
}
.btn-main:hover {
background: rgba(225, 51, 45, 0);
font-weight: 700;
letter-spacing: 1px;
}
.btn-main:hover rect {
stroke-width: 3;
stroke-dasharray: 74, 380;
stroke-dashoffset: 85;
transition: all 1.35s cubic-bezier(0.35, 1, 0.1, 1);
}
PHP:
<?php
//we need to get our variables first
$to = '[email protected]'; //the address to which the email will be sent
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$subject = 'CONTACT FORMULAR';
/*the $header variable is for the additional headers in the mail function,
we are assigning 2 values, first one is FROM and the second one is REPLY-TO.
That way when we want to reply the email gmail(or yahoo or hotmail...) will know
who are we replying to. */
$headers = "From: $email\r\n";
$headers .= "Reply-To: $email\r\n";
if ($_POST['submit']){
if(mail($to, $subject, $message, $headers)){
echo '<p>Thank you. We will answer your message in the shortest time possible.</p>'; // we are sending this text to the ajax request telling it that the mail is sent.
}else{
echo '<p>Something went wrong, go back and try again!</p>';// ... or this one to tell it that it wasn't sent
}
}
?>
我沒有足夠的知識,以便您的幫助深表感謝!