gpt4 book ai didi

php - 如何通过html表单将值记录到mysql数据库中

转载 作者:行者123 更新时间:2023-11-29 18:50:50 25 4
gpt4 key购买 nike

我已经制作了一个引导联系表单,但我真的不知道如何将提交的值插入到我的本地数据库(mysql)中。这是我的 html 表单:

<!--Contact Section-->
<div id="contact" class="container-fluid bg-grey">
<h2 class="text-center">CONTACT</h2>
<div class="row">
<div class="col-sm-5">
<p>Contact us and we'll get back to you within 24 hours.</p>
<p><span class="glyphicon glyphicon-map-marker"></span> Lagos, Nigeria</p>
<p><span class="glyphicon glyphicon-phone"></span><a href="tel:+2347068613892"> +234 7068613892 </a></p>


<p><span class="glyphicon glyphicon-envelope"></span><a href="mailto:sparkidea@gmail.com"> Sparkidea@gmail.com </a></p>
</div>
<form role="form" id="contactForm" class="contact-form" data-toggle="validator" class="shake">
<div class="col-sm-7 slideanim" method="post" action="php/mail-core.php">
<div class="row">
<div class="col-sm-6 form-group">
<div class="controls">
<input class="form-control" id="name" name="name" placeholder="Name" type="text" required required data-error="Please enter your name">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-6 form-group">
<div class="controls">
<input class="form-control" id="email" name="email" placeholder="Email" type="email" required required data-error="Please enter your email">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-6 form-group">
<div class="controls">
<input type="text" id="msg_subject" class="form-control" placeholder="Subject" required data-error="Please enter your message subject">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-6 form-group">
<div class="controls">
<input class="form-control" id="phone" name="phone" placeholder="Phone Number" type="tel" required required data-error="Please enter your Phone Number">
<div class="help-block with-errors"></div>
</div>
</div>
</div>
<div class="form-group">
<div class="controls">
<textarea class="form-control" id="message" name="message" placeholder="Message" rows="5" required data-error="Write your message"></textarea><br>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="row">
<div class="col-sm-12 form-group">
<button class="btn btn-default pull-right" type="submit" id="submit">Send</button>
<div id="msgSubmit" class="h3 text-center hidden"></div>
<div class="clearfix" style="padding-bottom: 20px;"></div>
</div>
</div>
</div>
</form>
</div>
</div>

我需要帮助记录插入到上面表格中的数据,谢谢!

最佳答案

我将使用一个小表单作为示例,但它当然也适用于您的表单。

<form action="post.php" method="POST">
<input name="login" type="text" />
<input name="password" type="password" />
<input type="submit" />
</form>

上面有一个使用 HTTP POST 方法发送其内容的表单。这意味着您将能够使用 PHP 中的 $_POST 数组获取字段内容。

post.php

<?php
$login = $_POST['login'];
$password = $_POST['password'];
?>

上面是post.php文件内容。当您提交表单时,字段内容将发送到此文件。如您所见,name 属性的内容是 $_POST 数组中的键。 name = 'login' 的输入可以在 $_POST['login']

中检索

关于php - 如何通过html表单将值记录到mysql数据库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44364836/

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