mmmmm da klasika!hvala!
Dopuna: 10 Jun 2008 15:03
e sad nece da upise sliku u bazu ovo sam nakucao sve lepo upise ali sliku ne!
<form action="Uneseno1.php" name="myform" ENCTYPE="multipart/form-data" method="post">
<table class="mytable">
<tr>
<td>Marka</td>
<td><input type ="text" name="marka" maxlenght="20" size="20"></td>
</tr>
<tr>
<td>Model</td>
<td><input type ="text" name="model" maxlenght ="20" size="20"></td>
</tr>
<tr>
<td>Cena</td>
<td><input type ="text" name ="cena" maxlenght ="20" size="20"></td>
</tr>
<tr>
<td>Godiste</td>
<td><input type="text" name="godiste" maxlenght="20" size="20"></td>
</tr>
<tr>
<td>Boja</td>
<td><input type="text" name="boja" maxlenght="20" size="20"></td>
</tr>
<tr>
<td>e-mail</td>
<td><input type="text" name="email" maxlenght="30" size="20"></td>
</tr>
<tr>
<td>Upload File:</td><td> <INPUT type="hidden" name="MAX_FILE_SIZE" value="1000000"> <input name="slike" type="file">
</td>
</tr>
<tr><td><input type="submit" name="submit" value="Update"></td></tr>
</table>
</form>
<?php
$marka = $_POST['marka'];
$model = $_POST['model'];
$cena = $_POST['cena'];
$godiste = $_POST['godiste'];
$boja = $_POST['boja'];
$email = $_POST['email'];
$slike = $_FILES['slike'];
if (!$marka || !$model || !$cena || !$godiste || !$boja || !$email || !$slike)
{
echo 'Niste uneli tražene podatke.<br>'.
'Molimo vas pokušajte ponovo.';
exit;
}
if(!get_magic_quotes_gpc())
{
$marka = addslashes($marka);
$model = addslashes($model);
$cena = doubleval($cena);
$godiste = addslashes($godiste);
$boja = addslashes($boja);
$email = addslashes($email);
$slike = addslashes(fread(fopen($slike, "r")));
}
@ $db = new mysqli('shadow','ford','escort','automobili');
if (mysqli_connect_errno())
{
echo 'Greska neuspesno povezivanje sa bazom.'.
'Molimo pokusajte ponovo.';
exit;
}
$query = "insert into automobili values
('".$marka."','".$model."','".$cena."','".$godiste."','".$boja."','".$email."','".$slike."')
";
$result = $db->query($query);
if($result)
echo 'Podaci su uspesno unešeni.<br>';
$db->close();
print("$marka<br>");
print("$model<br>");
print("$cena<br>");
print("$godiste<br>");
print("$boja<br>");
print('<p><a href="mailto:'.$email.'">'.$email.'</a></p>');
print("$slike<br>");
?>
<?php
$uploaded=0;
$utime=time();
$uday= date('d');
$umonth= date('m');
$uyear= date('y');
$udate=$umonth.$uday.$uyear;
$filename="a".$udate.$utime;
$target_path = "upload/";
$target_path = $target_path . basename( $_FILES['slike']['name']);
$_FILES['slike']['tmp_name']; // temp file
$target_path = "upload/"; //for my pc
$original_file = basename($_FILES['slike']['name']);
$pos = strpos($original_file,".",0);
$ext = trim(substr($original_file,$pos+1,strlen($original_file))," ");
$newfile = $filename . "." . $ext;
$target_path = $target_path . basename($newfile);
if(move_uploaded_file($_FILES['slike']['tmp_name'], $target_path)) {
$uploaded=1;
$message="Fajl:". basename( $_FILES['slike']['name']). " je uspešno poslat<br>";
}
else
{
$message="Doslo je do greške prilikom slanja, molimo vas pokušajte ponovo!";
}
echo $message;
if($uploaded==1)
print('<img src="upload/'.$newfile.'">');
?>
|