2014-11-14 35 views
1

我正在爲我的網站創建票務系統,現在它不會發送到我的數據庫。現在我無法找出它出錯的地方。所以我希望你們能幫助我。評論表未進入數據庫

這裏是我的代碼:

<?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> &nbsp &nbsp &nbsp &nbsp &nbsp &nbspUw naam : </label> 
<input id="username" type="text" name="username" required placeholder="Uw naam hier" /></p> 

<p><label> &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp E-Mail : </label> 
<input id="email" type="text" name="email" required placeholder="[email protected]" /></p> 

<p><label>Telefoonnummer : </label> 
    <input id="nummer" type="text" name="password" required placeholder="uw telefoonnummer hier" /></p> 

    <p><label>&nbsp &nbsp &nbsp &nbspOmschrijving 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)); 
} 
?> 

比較遺憾的是亂碼IM仍然使其更好,更容易閱讀。

+0

我們需要一些更多的細節。你可以編輯你的問題,幷包括你得到的任何錯誤消息。 – dan08 2014-11-14 21:05:24

+0

多數民衆贊成這個問題,它不會給我任何錯誤,它只是不會添加任何東西 – 2014-11-14 21:07:07

+0

'$ nummer = $ _POST [「nummer」];''和'名稱=「密碼」最有可能的配對。你不能只依靠「id」id =「nummer」' – 2014-11-14 21:07:44

回答

2

從代碼:

<p><label>Telefoonnummer : </label> 
<input id="nummer" type="text" name="password" required placeholder="uw telefoonnummer hier" /></p> 

變化name="password"name="nummer"

+0

確保你在提交之前刷新表單。在代碼中看不到更多的錯誤。檢查它是否在阻止。 – hasnat 2014-11-14 21:12:30

+0

即時對不起,我刪除了反應,因爲它的作品現在我編輯了錯誤的東西(測試頁,我有)。我現在覺得很蠢,但是謝謝你! – 2014-11-14 21:13:56