daily pastebin goal
84%
SHARE
TWEET

Untitled

a guest Dec 6th, 2016 23 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. if(isset($_POST['dodaj']))
  3. {
  4. $dbhost = 'localhost';
  5. $dbuser = 'root';
  6. $dbpass = 'usbw';
  7. $db_name = 'zapisi';
  8. $tbl_name = 'vneseni';
  9. $ftp_user = 'ugd';
  10. $ftp_pass = 'kiko';
  11. $ftp_server = "localhost";
  12.  
  13. $conn = mysql_connect($dbhost, $dbuser, $dbpass);
  14. if(! $conn )
  15. {
  16.   die('Could not connect: ' . mysql_error());
  17. }
  18. mysql_select_db("$db_name")or die("cannot select DB");
  19.  
  20.  
  21.  
  22.  
  23. $ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
  24. // login with username and password
  25. $login_result = ftp_login($ftp_conn, $ftp_user, $ftp_pass);
  26.  
  27.  
  28. // check connection
  29. if ((!$ftp_conn) || (!$login_result)) {
  30.        echo "FTP connection has failed!";
  31.        echo "Attempted to connect to $ftp_server for user $ftp_user";
  32.        exit;
  33.    } else {
  34.        echo "Connected to $ftp_server, for user $ftp_user";
  35.    }
  36.  
  37.  
  38. $Vid = $_POST['vid'];
  39. $Cena = $_POST['cena'];
  40. $Br_Std = $_POST['br_std'];
  41. $Naselba = $_POST['naselba'];
  42. $Dogovor = $_POST['dogovor'];
  43. $Ime = $_POST['ime'];
  44. $Mob = $_POST['mob'];
  45. $Opis = $_POST['opis'];
  46. $uploadDir = 'http://localhost:8080/UGDSmeshtaj/'.'img/';
  47. $fileName = $_FILES['slika']['name'];
  48. $filePath = $uploadDir . $fileName;
  49.  
  50. if(move_uploaded_file($_FILES["slika"]["tmp_name"],"img/".$_FILES["slika"]["name"]))
  51. {
  52. // If file has uploaded successfully, store its name in data base
  53. $query_image = "INSERT INTO $tbl_name(vid,cena,br_std,naselba,dogovor,ime,mob,opis,slika) VALUES ('".$Vid."','".$Cena."','".$Br_Std."','".$Naselba."','".$Dogovor."','".$Ime."','".$Mob."','".$Opis."','".$filePath."')";
  54. if(mysql_query($query_image))
  55. {
  56. echo "Stored in: " . "img/" . $_FILES["slika"]["name"];
  57. }
  58. else
  59. {
  60. echo 'File name not stored in database';
  61. }
  62. }
  63. else{echo 'File not uploaded';}
  64.  
  65. }
  66.  
  67.  
  68.  
  69.  
  70.  
  71. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top