Hallo dies ist meine Form Code:Bilder mit Anmeldeformular
echo "<form method=\"POST\" action=\"\">\n";
echo "<td>User Id</td><td> <input type=\"text\" name=\"user_id\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Full Name</td><td> <input type=\"text\" name=\"full_name\"> </td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Qualification</td><td> <input type=\"text\" name=\"qualification\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Locality</td><td> <input type=\"text\" name=\"locality\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Description</td><td> <input type=\"text\" name=\"description\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Languages Known</td><td><input type=\"text\" name=\"language\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Experience</td><td><input type=\"text\" name=\"experience\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Dress</td><td><input type=\"text\" name=\"dress_code\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Bank Details</td><td><input type=\"text\" name=\"bank_details\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Two Wheelers</td><td><input type=\"text\" name=\"two_wheeler\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Threshold</td><td><input type=\"text\" name=\"threshold\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input name=\"pic1\" type=\"file\"></td><td><input name=\"pic\" type=\"submit\" value=\"Upload Image\"></td>\n"; // Kindly check this line
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Photo 2</td><td><input type=\"text\" name=\"pic2\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Photo 3</td><td><input type=\"text\" name=\"pic3\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Photo 4</td><td><input type=\"text\" name=\"pic4\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Photo 5</td><td><input type=\"text\" name=\"pic5\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>ID Number</td><td><input type=\"text\" name=\"id_proof\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Contact Details</td><td><input type=\"text\" name=\"contact_details\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Date</td><td><input type=\"text\" name=\"datetime_added\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input id=\"button\" type=\"submit\" name=\"btn-signup\" value=\"Sign-Up\"></td>\n";
echo "</tr>\n";
echo "</form>\n";
ich eine Verwirrung haben, dass, wie kann ich mit form.Below ein Bild in der Datenbank hochzuladen ist meine PHP-Datei
if(isset($_POST['btn-signup']))
{
$user_id = mysql_real_escape_string($_POST['user_id']);
$full_name = mysql_real_escape_string($_POST['full_name']);
$qualification = mysql_real_escape_string($_POST['qualification']);
$locality = mysql_real_escape_string($_POST['locality']);
$description = mysql_real_escape_string($_POST['description']);
$language = mysql_real_escape_string($_POST['language']);
$experience = mysql_real_escape_string($_POST['experience']);
$dress_code = mysql_real_escape_string($_POST['dress_code']);
$bank_details = mysql_real_escape_string($_POST['bank_details']);
$two_wheeler = mysql_real_escape_string($_POST['two_wheeler']);
$threshold = mysql_real_escape_string($_POST['threshold']);
$pic1 = mysql_real_escape_string($_POST['pic1']);
$pic2 = mysql_real_escape_string($_POST['pic2']);
$pic3 = mysql_real_escape_string($_POST['pic3']);
$pic4 = mysql_real_escape_string($_POST['pic4']);
$pic5 = mysql_real_escape_string($_POST['pic5']);
$id_proof = mysql_real_escape_string($_POST['id_proof']);
$contact_details = mysql_real_escape_string($_POST['contact_details']);
$datetime_added = mysql_real_escape_string($_POST['dtetime_added']);
$uname = trim($uname);
$email = trim($email);
$upass = trim($upass);
$target = "upload/";
$target = $target . basename($_FILES['photo']['name']);
//This gets all the other information from the form
$pic1=($_FILES['photo']['name']);
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file ". basename($_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
// email exist or not
$query = "SELECT user_id FROM promoter WHERE user_id='$user_id'";
$result = mysql_query($query);
$count = mysql_num_rows($result); // if email not found then register
if($count == 0){
if(mysql_query("INSERT INTO promoter(user_id,full_name,qualification,locality,description,language,experience,dress_code,bank_details,two_wheeler,threshold,pic2,pic3,pic4,pic5,id_proof,contact_details,datetime_added, target) VALUES('$user_id','$full_name','$qualification','$locality','$description','$language','$experience','$dress_code','$bank_details','$two_wheeler','$threshold','$pic2','$pic3','$pic4','$pic5','$id_proof','$contact_details','$datetime_added','$target')"))
{
?>
<script>alert('successfully registered ');</script>
<?php
}
else
{
?>
<script>alert('error while registering you...');</script>
<?php
}
}
else{
?>
<script>alert('Sorry Email ID already taken ...');</script>
<?php
}
}
Dort habe ich fünf Fotooptionen in der Form angegeben, aber ich teste nur im ersten Bild1. Hilf mir, wie ich die Bilddatei mit meinem Code hochladen kann. Ich bin verwirrt, wie man Bild hinzufügt oder den Bildweg hinzufügen muss. Bitte korrigieren Sie meinen Code.
Sie haben die Image-Pfad in der Datenbank hinzufügen inorder, um es abzurufen später – coder
Zunächst einmal Gebrauch mysqli_real_escape_string statt mysql_real_escape_string – Lokesh
Und Sie brauchen nicht die zu speichern Bild in der Datenbank speichern Sie den Pfad eines Bildes in der Datenbank, – Lokesh