gpt4 book ai didi

javascript - 如何使此联系​​表起作用?

转载 作者:太空宇宙 更新时间:2023-11-04 10:16:05 25 4
gpt4 key购买 nike

我无法编辑此“联系我们”表单代码工作并将消息发送到我的邮箱。

假设我想将消息发送到我的电子邮件:doherty@noob.com,我该如何编辑这段代码来完成任务?

<div class="conatct-form">
<ul class="form">
<li>
<input type="text" class="text" value="Name*" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Name*';}" >
</li>
<li>
<input type="text" class="text" value="Email*" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email*';}" >
</li>
<li>
<textarea value="Message*:" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Your Message*';}">Message*</textarea>
</li>
<div class="sub-button">
<input type="submit" value="SEND">
</div>

</ul>
</div>

最佳答案

我已经优化了您的代码并添加了一些 PHP 代码

PHP代码

 <?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

if (isset($name, $email, $message)) {
// Insert into database
$query = mysql_query("INSERT INTO contacts ...");

if ($query) {
// send email using phpmailer, sendmail, ...
mail($mail, 'Subject', $message, '...');
}
}
?>

HTML

<form id="contact-form" method="post">
<ul>
<li>
<!--
Substituting the code below
<input type="text"
value="Name *"
onfocus="this.value=''"
onblur="if (this.value == '') {this.value = 'Name *'}" />

use the placeholder attribute instead
-->
<input type="text" name="name" placeholder="Name *" />
</li>
<li>
<input type="text" name="email" placeholder="Email *" />
</li>
<li>
<textarea name="message" placeholder="Message *"></textarea>
</li>
<li>
<input type="submit" value="Send" />
</li>
</ul>
</form>

关于javascript - 如何使此联系​​表起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37235317/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com