无法将数据插入数据库,但我没有错误

时间:2017-04-27 17:09:17

标签: php database

你能帮帮我吗?

我在表单中输入的数据无法保存在我的数据库中,但我的代码中没有错误。

这是我的代码:

<body>
<?php
    require('dbconevent.php');

         if(isset($_POST['submit'])){
          $eventname = addslashes($_POST['event_name']); //get values
          $register_name = addslashes($_POST['register_name']); 
          $register_email = addslashes($_POST['register_email']);
          $register_number = addslashes($_POST['register_number']);
          $sql = "Insert into register(event_name, register_name, register_email, register_number) values ('".$eventname."', '".$register_name."',  '".$register_email."', '".$register_number."');";
           echo $sql;return; 
           $res = mysqli_query($con,$sql); //res for result just a variable name, mysqli_query() returns true or false value upon excecuting sql
           if($res){ //if sql [ inserted ] is true
              echo 'Added!';
             }else{
              echo 'Something Went Wrong'; //Sql error or db error
            }
    }

?>
<script>
  alert('You are registered!');
  window.location = 'event.php';
</script>
</body>

我希望有人可以帮助我。谢谢

0 个答案:

没有答案