php help

imeshSJ

Member
Jul 26, 2007
872
12
0
<?php

//This is the directory where images will be saved
$target = "images/";
$target = $target . basename( $_FILES['photo']['name']);

//This gets all the other information from the form
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$pic=($_FILES['photo']['name']);

// Connects to your Database
mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error()) ;
mysql_select_db("Database_Name") or die(mysql_error()) ;

//Writes the information to the database
mysql_query("INSERT INTO `employees` VALUES ('$name', '$email', '$phone', '$pic')") ;

//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.";
}
?>

(mata mekata photos 5 k upload karanna onnee. mama code eka wenas kala eth hariyannee naaa. meka wenas wenne komada kiyanawada:(
 

mldarshana

Well-known member
  • Apr 2, 2007
    34,059
    1,404
    113
    ආශ්චර්ය අභියස :nerd:
    put 5 FileField buttons

    and when u capture data use a FOR Loop

    for($x=1;$x<=5;$x++){
    $image_name = $_FILES[$x.'image']['name'];
    $tmp = $_FILES[$x.'image']['tmp_name'];
    $type = $_FILES[$x.'image']['type'];
    $size = $_FILES[$x.'image']['type'];
    if($x == 1)
    if($size == "") {
    // u can validate here
    }
    }