简体   繁体   中英

how to record value via html form into mysql database

I have made a bootstrap contact form but i don't really know how to insert the submitted values into my local database(mysql). Here's my html form:

<!--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>

I need help with recording the data inserted into the form above, thanks!

I will use a little form as example but it also works with your form of course.

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

Above there is a form that send its content using the HTTP POST method. It means that you'll be able to get the fields content using the $_POST array in PHP.

post.php

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

Above there is the post.php file content. When you submit your form, fields content is sent to this file. As you can see, the content of the name attribute is the key in the $_POST array. The input with name = 'login' can be retrieved in $_POST['login']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM