输入不使用UI框架提交给MySQL

时间:2018-09-05 20:53:55

标签: php html html5 onsen-ui onsen-ui2

我正在使用输入通过PHP将数据提交到MySQL。它在HTML input中可以正常工作,但不能使用Onsen UI框架标签ons-input来工作。知道为什么吗?

普通HTML(有效)

<form action="insert.php" method="POST">
Firstname: <input type="text" name="fname" required /><br>
Lastname: <input type="text" name="lname" require /><br>
<input type="submit" />
</form>

Onsen UI框架HTML(无效)

<form action="insert.php" method="POST">
Firstname: <ons-input type="text" name="fname" required />
Lastname: <ons-input type="text" name="lname" required />
<input type="submit" />
</form>

insert.php

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "testdb";


$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql  = "INSERT INTO exampledb (fname, lname)
  VALUES ('".$_POST["fname"]."','".$_POST["lname"]."')";

if ($conn->multi_query($sql) === TRUE) {
echo "New records created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

0 个答案:

没有答案