我正在为我的网站创建一个票务系统,现在它不会发送到我的数据库。现在我无法找出它出错的地方。所以我希望你们能帮帮我。
这是我的代码:
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
include('connect.php');
session_start();
echo "Aan deze pagina word gewerkt, gebruik deze niet zolang wij hier mee bezig zijn";
//filled check
if (isset($_POST["username"]) && isset($_POST["email"])&& isset($_POST["nummer"])&& isset($_POST["comment"])){
$username = $_POST["username"];
$email = $_POST["email"];
$nummer= $_POST["nummer"];
$comment= $_POST["comment"];
//prepered insert and finished message
$stmt = $connection->prepare("INSERT INTO `comments` (username,email,nummer,comment) VALUES(?,?,?,?)");
$stmt->bind_param("ssss", $username, $email, $nummer, $comment);
$stmt->execute();
$msg = "De reparatie is aangevraagd. Er zal binnenkort contact met u worden op genomen.";
}
?>
<!DOCTYPE html>
<html>
<body>
<title>mytitle</title>
<div id="wrapper">
<head>
<link rel="stylesheet" href="styles.css">
</head>
<h1 id=logo>
<a href=""> </a>
</h1>
<?php
if(isset($msg) && !empty($msg)){
echo $msg;
}
?>
<div class="ticket-form">
<h1>Reparatie aanvraag</h1>
<form action="" method="POST">
<p><label>            Uw naam : </label>
<input id="username" type="text" name="username" required placeholder="Uw naam hier" /></p>
<p><label>                 E-Mail : </label>
<input id="email" type="text" name="email" required placeholder="naam@email.com" /></p>
<p><label>Telefoonnummer : </label>
<input id="nummer" type="text" name="password" required placeholder="uw telefoonnummer hier" /></p>
<p><label>       Omschrijving van het probleem : </label>
<textarea name="comment" rows="5" cols="40" required placeholder="Omschijving van het probleem"></textarea></p>
<input class="btn tick" type="submit" name="submit" value="Verstuur reparatie aanvraag" />
</form>
</div>
</div>
</body>
</html>
然后提到了contact.php。 (这个是正常的,因为我将其用于其他表格进行注册。)
<?php
$servername = "localhost";
$username = "sqluser";
$password = "Welkom01!";
$dbname = "users";
$connection = mysqli_connect($servername, $username, $password);
if (!$connection){
die("Database Connection Failed". mysqli_error($connection));
}
$select_db = mysqli_select_db($connection, $dbname);
if (!$select_db){
die("Database Selection Failed" . mysqli_error($connection));
}
?>
对于凌乱的代码我很抱歉,它仍然使它更好更容易阅读。
答案 0 :(得分:2)
从你的代码:
<p><label>Telefoonnummer : </label>
<input id="nummer" type="text" name="password" required placeholder="uw telefoonnummer hier" /></p>
将name="password"
更改为name="nummer"