2017-07-14 44 views
1

這是我創建的註冊系統的代碼。每次我得到相同的輸出說「用戶未註冊」。我究竟做錯了什麼?我在下面添加了我的php和html代碼。我的html表單值不會發送到MYSQL數據庫

<?php 
 
require_once('connect.php'); 
 
    if (isset($_POST['submit']) && !empty($_POST['submit'])){ 
 
     $date = $_POST['date']; 
 
     $name = $_POST['name']; 
 
     $email = $_POST['email']; 
 
     $password = $_POST['password']; 
 
     $gender = $_POST['gender']; 
 
     $phone = $_POST['phone']; 
 
     $address1 = $_POST['address1']; 
 
     $address2 = $_POST['address2']; 
 
     $country = $_POST['country']; 
 
     $zip = $_POST['zip']; 
 
     $city = $_POST['city']; 
 
     $state = $_POST['state']; 
 
    $sql = "INSERT INTO `usermanagement` (date, name, email, password, gender, phone, address1, address2, country, zip, city, state) VALUES('$date', '$name', '$email', '$password', '$gender', '$phone','$address1', '$address2', '$country', '$zip', '$city', '$state')";// 
 
     $result=mysqli_query($connection, $sql); 
 
     if ($result){ 
 
      echo "User succesfully refgistered"; 
 
     } 
 
     else { 
 
      echo "User not registered"; 
 
} 
 
    } 
 
    
 
    ?> 
 
<form method="post"; style="width:1000px;"> 
 
     <input name="dateob" type="text" id="datepicker" class="form-control" style="width:200px;margin-bottom:-20px;margin-left:220px;" /> 
 
    <input type="text" name="name" required placeholder="Full Name*" class="form-control" style="width:200px;margin-top:-42px;" /> 
 
    <div class="form-group"> 
 
     <input type="email" name="email" required placeholder="Email*" class="form-control" style="width:200px;margin-top:20px;" /> 
 
     <input type="password" name="password" required placeholder="Password*" class="form-control" style="width:200px;margin-top:-43px;margin-left:220px;" /> 
 
    </div> 
 
    <div class="form-group"></div> 
 
............. 
 
     <input type="text" name="state" required placeholder="State*" class="form-control" style="margin-top:-42px;width:200px;margin-left:210px;" /> 
 
     <input class="btn btn-primary btn-block" value="Next" name="submit" type="submit" style="background-color:rgb(51,193,159);"/>

+0

你不檢查錯誤。 –

+1

你應該嘗試打印mysql_error(); mysqli_query($ connection,$ sql)或die(mysqli_error($ db)); –

+1

'date'是一個MySQL保留字。請儘量避免使用它作爲列名。 – Pupil

回答

1

我想你應該從'usermanagement'刪除',因爲這是它是如何讀你的表的名稱

+0

所以我應該把它作爲「INSERT INTO usermanagement」 –

+0

是的,它工作嗎? –

相關問題