<?php
include "session.php";
$con=mysqli_connect("localhost","root","","project");
if (isset($_POST['submit'])) {
$a=$_POST['title'];
$b=$_POST['catagory'];
$c=$_POST['textarea'];
$g=$_FILES['upload']['name'];
$tmp_name = $_FILES['upload']['tmp_name'];
$d=$_POST['country'];
$e=$_POST['city'];
$f=$_POST['mobilenumber'];
if (isset ($g)) {
if (!empty($g)) {
$location = 'uploads/';
if (move_uploaded_file($tmp_name, $location.$g)){
$query = "insert into productadd(title,catagory,textarea,upload,country,city,mobilenumber) VALUES ('$a','$b','$c','$g','$d','$e','$f')";
$result = mysqli_query($con, $query);
if($result){
$smsg = "Successfully Submitted";
}else{
$fmsg ="Fail";
}
}
}
}
}
mysqli_close($con);
?>
Hochladen von Bildern Fehler, in php mysql
<form action="" method="post" enctype="multipart/form-data">
<div>
<input type = "text" id = "title" name = "title" required placeholder=" " />
<label for ="title"> Title</label>
</div>
<div>
<select name="category" id="select">
<option>--Select Category--</option>
<option>Website</option>
<option>Android App</option>
<option>IOS App</option>
<option>Other</option>
</select>
<label for = "email"> Category</label>
<div class="requirements">
Please Enter category.
</div>
</div>
<div>
<textarea id="textarea" name="textarea" cols="25" rows="7"></textarea>
<label for ="textarea"> Descriptions</label>
</div>
<div>
<input type="file" id="upload" name="upload" placeholder=" " />
<input type="txt" id="name" name="name" placeholder=" " />
</div>
<div>
<select id="country"name="country">
<option value="">Country...</option>
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">Other</option>
</select>
<label for = "country">Country</label>
</div>
<div>
<input type="text" id="city" name="city" required placeholder=" " />
<label for="city">City</label>
</div>
<div>
<input type="text" id="mobilenumber" name="mobilenumber" required placeholder=" " />
<label for="mobilenumber">Mobile #</label>
</div>
<div>
<center>
</div>
<center>
<input type="submit" id="submit" name="submit" value="Submit" />
</center>
</form>
Ich bin zum Hochladen von Bildern auf MySQL DB nicht in der Lage.
Code bei undefinierten Index "Upload" -Fehler bei 9, 10 Zeilen. Aber wenn ich if(isset($_FILES['upload'])
verwende, dann wird dieser Fehler nicht angezeigt, aber das Bild wird nicht in die Datenbank hochgeladen.
Bitte, wenn jemand wissen, wie Sie dieses Problem zu lösen, bitte geben Sie Ihre Meinung.
Mögliche Duplikat [PHP: "Hinweis: Nicht definierte Variable", "Notice: Undefined index" und "Hinweis: Undefined offset"] (http://stackoverflow.com/questions/4261133/php -notice-undefined-variable-notice-undefined-index-und-notice-undef) –
möglicherweise Fehler ist nicht hier. Zeigen Sie Ihren Beitrag Formular oder zeigen Sie Ihre HTML-Codierung, wo Sie Ihr Bild hochladen –
Formular-Code haben ein Problem mit der Benennung. Zeig uns. hast du html wie folgt: -' 'auch' enctype = "multipart/form-data" 'benötigt in form –