The code looks like this:
html
<form action="contact.php" method="post" enctype="multipart/form-data" onsubmit="return Validare();">
<input type="text" name="nume" value="Nume" class="contact" id="Nume" onclick="if(this.value=='Nume')this.value='';" onblur="if(this.value.replace(/^\s+|\s+$/g,'')=='')this.value='Nume'" /><font color="red">*</font><br />
<input type="text" name="email" value="Email" class="contact" id="Email" onclick="if(this.value=='Email')this.value='';" onblur="if(this.value.replace(/^\s+|\s+$/g,'')=='')this.value='Email'" /><font color="red">*</font><br />
<input type="text" name="telefon" value="Telefon" class="contact" id="Telefon" onclick="if(this.value=='Telefon')this.value='';" onblur="if(this.value.replace(/^\s+|\s+$/g,'')=='')this.value='Telefon'" /><br />
<textarea name="mesaj" rows="10" class="contact" id="Mesaj" onclick="if(this.value=='Mesaj')this.value='';" onblur="if(this.value.replace(/^\s+|\s+$/g,'')=='')this.value='Mesaj'">Mesaj</textarea>
<input type="file" name="file[]" />
<input type="file" name="file[]" />
<input type="file" name="file[]" />
<input type="submit" value="Trimite" />
</form>
php
for($i=0; $i<3; $i++){
if($_FILES["file"]["size"][$i] > 0){
$rand = rand(10000, 99999);
$name = $rand.rand(10000, 99999).$_FILES["file"]["name"][$i];
$tmp_name = $_FILES["file"]["tmp_name"][$i];
$target_path_big = "http://biroutraduceri.net/fisiere/".$name;
move_uploaded_file($tmp_name, "fisiere/".$name);
}
}
javascript
<script>
function Validare(){
if(document.getElementById("Nume").value.replace(/^\s+|\s+$/g,'') == "" || document.getElementById("Nume").value.replace(/^\s+|\s+$/g,'') == "Nume"){
alert("Numele nu este valid!");
return false;
}
if(document.getElementById("Email").value.replace(/^\s+|\s+$/g,'') == "" || document.getElementById("Email").value.replace(/^\s+|\s+$/g,'') == "Email"){
alert("Email-ul nu este valid!");
return false;
}
if(document.getElementById("Mesaj").value.replace(/^\s+|\s+$/g,'') == "" || document.getElementById("Mesaj").value.replace(/^\s+|\s+$/g,'') == "Mesaj"){
alert("Mesajul nu este valid!");
return false;
}
return true;
}
</script>
When I press submit nothing happen. The file isn't uploaded.
Where I'm wrong???