我在表单中输入的数据无法保存在我的数据库中,但我的代码中没有错误。
这是我的代码:
<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>
我希望有人可以帮助我。谢谢