Log in

View Full Version : insert options!!



pavmoxo
06-01-2006, 10:48 AM
I choose this code for upload 3 files for certain directories but don't know how to do if certain file fields are empty(the files aren't obligator fields):



if(is_uploaded_file($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['doc1']['tmp_name']) && is_uploaded_file($_FILES['doc2']['tmp_name'])) {
move_uploaded_file($_FILES['file']['tmp_name'], "imagens/outras/".$_FILES['file']['name']);
move_uploaded_file($_FILES['doc1']['tmp_name'], "ageral/".$_FILES['doc1']['name']);
move_uploaded_file($_FILES['doc2']['tmp_name'], "ageral/".$_FILES['doc2']['name']);
if (is_file("imagens/outras/".$_FILES['file']['name']) && is_file("ageral/".$_FILES['doc1']['name']) && is_file("ageral/".$_FILES['doc2']['name'])) {
insert_ageral($_POST["Bday"], $_POST["Bmonth"], $_POST["Byear"], $_POST["Eday"], $_POST["Emonth"], $_POST["Eyear"], $_POST["Bhour"], $_POST["Bmin"], $_POST["Ehour"], $_POST["Emin"], "imagens/outras/".$_FILES['file']['name'], $_POST["agenda"], $_POST["titulo_geral"], $_POST["comentario"], $_POST["item1"], $_POST["desc_item1"], $_POST["item2"], $_POST["desc_item2"], $_POST["item3"], $_POST["desc_item3"], $_POST["item4"], $_POST["desc_item4"], $_POST["item5"], $_POST["desc_item5"], $_POST["item6"], $_POST["desc_item6"], $_POST["titulo_prog"], $_POST["desc_prog"], $_POST["site"], $_POST["site_text"], $_POST["email"], $_POST["email_text"], "ageral/".$_FILES['doc1']['name'], $_POST["doc1_text"], "ageral/".$_FILES['doc2']['name'], $_POST["doc2_text"], $_POST["destaque"], $_POST["ancora"], date("Y-m-d"), 1);
echo "<script>alert('Registo adicionado com sucesso.');</script>";
}
} else {
insert_ageral($_POST["Bday"], $_POST["Bmonth"], $_POST["Byear"], $_POST["Eday"], $_POST["Emonth"], $_POST["Eyear"], $_POST["Bhour"], $_POST["Bmin"], $_POST["Ehour"], $_POST["Emin"], NULL, $_POST["agenda"], $_POST["titulo_geral"], $_POST["comentario"], $_POST["item1"], $_POST["desc_item1"], $_POST["item2"], $_POST["desc_item2"], $_POST["item3"], $_POST["desc_item3"], $_POST["item4"], $_POST["desc_item4"], $_POST["item5"], $_POST["desc_item5"], $_POST["item6"], $_POST["desc_item6"], $_POST["titulo_prog"], $_POST["desc_prog"], $_POST["site"], $_POST["site_text"], $_POST["email"], $_POST["email_text"], NULL, NULL, NULL, NULL, $_POST["destaque"], $_POST["ancora"], date("Y-m-d"), 1);
echo "<script>alert('Registo adicionado sem ficheiros.');</script>";
}

For example in this code, if the file fields are with path to a file, it shows "'Registo adicionado com sucesso" if the fields are empty it shows "'Registo adicionado sem ficheiros". But are others cases if one or more of them are empty. Can you help me??