2017-07-14 43 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

是的,它工作吗? –

相关问题