本文介绍了联系表格到数据库不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我正在尝试通过联系表单在数据库中插入文本。由于一个原因,它不起作用,也没有任何错误。我似乎无法找到错误。有人可以帮帮我吗?



这是我的代码:





Hi there,

I'm trying to insert text in a database through a contact form. For one reason it doesn't work and it also doesn't give any errors. I can't seem to find what is wrong. Anyone could help me?

Here is my code:


 <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="voornaam">Voornaam *</label>
                                <input id="voornaam" type="text" name="voornaam" class="form-control" placeholder="Please enter your firstname *" required="required" data-error="Firstname is required.">
                                <div class="help-block with-errors"></div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="achternaam">Achternaam *</label>
                                <input id="achternaam" type="text" name="achternaam" class="form-control" placeholder="Please enter your lastname *" required="required" data-error="Lastname is required.">
                                <div class="help-block with-errors"></div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="email">Email *</label>
                                <input id="email" type="email" name="email" class="form-control" placeholder="Please enter your email *" required="required" data-error="Valid email is required.">
                                <div class="help-block with-errors"></div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="nummer">Telefoonnummer</label>
                                <input id="nummer" type="tel" name="nummer" class="form-control" placeholder="Please enter your phone">
                                <div class="help-block with-errors"></div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="bericht">Bericht *</label>
                                <textarea id="bericht" name="bericht" class="form-control" placeholder="Message for me *" rows="4" required="required" data-error="Please,leave us a message."></textarea>
                                <div class="help-block with-errors"></div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <input type="submit" name="sumbit" class="btn btn-success btn-send" value="Send message">
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <p class="text-muted"></p>
                        </div>
                    </div>
                </div>

            </form>

        </div>

    </div>

</div>
<?php
$db_server = "localhost";
$db_username = "root";
$db_password = "";
$db_database = "meubelfabriek";
$conn = new PDO("mysql:host=$db_server;dbname=$db_database", $db_username, $db_password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if (isset($_POST['submit']))
{
$voornaam = $_POST['voornaam'];
$achternaam = $_POST['achternaam'];
$nummer = $_POST['nummer'];
$email = $_POST['email'];
$bericht = $_POST['bericht'];

$stmt = $conn->prepare("INSERT INTO `inbox` (voornaam, achternaam, nummer, email, bericht) VALUES
(:voornaam, :achternaam, :nummer, :email, :bericht)");
$stmt->execute(array(":voornaam"=>$voornaam, ":achternaam"=>$achternaam, ":nummer"=>$nummer, ":email"=>$email, ":bericht"=>$bericht));

}
?>





我尝试了什么:



没有,因为我没有看到任何错误。



What I have tried:

Nothing as I don't see anything wrong.

推荐答案




这篇关于联系表格到数据库不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 11:53