我正在尝试使用php进行调查。提交答案时,我没有收到任何错误消息,但是它们没有出现在我的数据库中。
使用php是我的新手。
include('config.inc.php'); //DB-Connection
$e1 = $_POST['11'];
$e2 = $_POST["12"];
$e3a = $_POST["13a"];
$e3b = $_POST["13b"];
$e3c = $_POST["13c"];
$e3d = $_POST["13d"];
$e3e = $_POST["13e"];
$e3f = $_POST["13f"];
$e3g = $_POST["13g"];
$e3h = $_POST["13h"];
if (!empty($e1 or $e2 or $e3a or $e3b or $e3c or $e3d or $e3e or $e3f or $e3g or $e3h )) {
$result = mysqli_query($connection,
'INSERT INTO umfrage1
(q1,q2,q3a,q3b,q3c,q3d,q3e,q3f,q3g,q3h)
VALUES
($e1, $e2, $e3a, $e3b, $e3c, $e3d, $e3e, $e3f, $e3g, $e3h)');
echo "<p>Thank you for participating in our survey:D</p>";
} else {
echo "<p>You did not answer to all questions, please try again.</p>";
}
这是config.inc.php的内容:
$host = "localhost";
$user= "root";
$passwort = "";
$datenbank = "testdatenbank";
$connection = mysqli_connect($host, $user, $passwort) OR DIE ("No connection!");
$db = mysqli_select_db($connection, $datenbank) OR DIE (mysqli_error($connection));