Input does not submit to MySQL using UI framework

168 views Asked by At

I am using input to submit data to MySQL using PHP. It works fine in HTML input but it doesn't work using the Onsen UI framework tag ons-input. Any idea why?

Normal HTML (it works)

<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 framework HTML (it does not work)

<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

There are 0 answers