[英]Crud application wont instert into database
我的應用程序不會插入數據庫,並且不會給我任何錯誤。 如果我的問題重復,請重定向到原始問題,謝謝。
我的PHP代碼:
<?php
include_once("dbconfig.php");
if(isset($_POST['submit'])){
/*$targetDir = "slike/";
$allowTypes = array('jpg','png','jpeg','gif');
$statusMsg = $errorMsg = $insertValuesSQL = $errorUpload = $errorUploadType = '';*/
$image = $_FILES['files']['tmp_name'];
$file = addslashes(file_get_contents($image));
$name = mysqli_real_escape_string($mysqli, $_POST['ime']);
$group=mysqli_real_escape_string($mysqli,$_POST['grupa']);
$semi=mysqli_real_escape_string($mysqli,$_POST['podgrupa']);
$price=mysqli_real_escape_string($mysqli,$_POST['cena']);
if(empty($name) || empty($group) || empty($semi)||empty($price)) {
echo "<font color='red'>Namesteno je da sve moraju da budu popunjene.</font><br/>";
if(empty($name)) {
echo "<font color='red'>Ime je prazno.</font><br/>";
}
if(empty($group)) {
echo "<font color='red'>Grupa je prazna.</font><br/>";
}
if(empty($semi)) {
echo "<font color='red'>Podgrupa je prazna.</font><br/>";
}
if(empty($price)){
echo "<font color='red'>Cena je prazna.</font><br/>";
}
}
else{
$result = mysqli_query($mysqli, "INSERT INTO slike(ime,grupa,podgrupa,cena,slika) VALUES('$name','$group','$semi','$price','$file')");
echo "<font color='green'>Data added successfully.";
}
}
?>
我的html:
</div>
<div class="content">
<form action="" method="post" enctype="multipart/form-data">
Slike biras ovde:
<input type="file" name="files">
<p>IME</p>
<input type="text" name="ime">
<p>GRUPA</p>
<input type="text" name="grupa">
<p>PODGRUPA</p>
<input type="text" name="podgrupa">
<p>CENA</p>
<input type="text" name="cena">
<input type="submit" name="submit" value="UPISI">
</form>
如果您需要更多代碼,我會在回復中發布。 問題是我收到消息“數據添加成功”,但是當我轉到數據庫時,它為空。 謝謝任何幫助我的人。
<form action="/your_php_file.php" method="post" enctype="multipart/form-data">
請為您的表格設置操作,該表格應轉到您的php文件中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.