我在 html div 内容中加载 PHP 文件时遇到问题。它加载正常,但不将数据发送到数据库。控制台没有问题。
在div中加载form.php
$(document).ready(function(){
$("#Formularz").click(function(){
$(".container").load('formularz.php');
});
});
表单.php 文件:
<?php
$host = "localhost";
$user = "root";
$password = "";
$dbname = "sklep_komputerowy";
$conn = mysqli_connect($host,$user,$password,$dbname);
if(isset($_POST['save']))
{
$id = $_POST['id'];
$nazwa = $_POST['nazwa'] ;
$typ = $_POST['typ'] ;
$cena = $_POST['cena'] ;
$sql = "INSERT INTO `asortyment` (id,nazwa, typ, cena) VALUES ('$id','$nazwa', '$typ', '$cena') ";
mysqli_query($conn,$sql)
or die ("essa");
}
?>
<form method="post">
ID <input type="text" name= "id" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /><br>
Nazwa <input type="text" name="nazwa" /><br>
Typ <input type="text" name="typ" /><br>
Cena <input type="text" name= "cena" onkeypress='return event.charCode >= 48 && event.charCode <= 57' /><br>
<input type="submit" name="save" value="Dodaj"/>
</form>
慕的地10843